Skip to content

feat: replace polling with event-driven notifications#1

Merged
bottlebrushes merged 1 commit intomainfrom
bettercoderthanyou/remove-polling
Jan 16, 2026
Merged

feat: replace polling with event-driven notifications#1
bottlebrushes merged 1 commit intomainfrom
bettercoderthanyou/remove-polling

Conversation

@bottlebrushes
Copy link
Copy Markdown
Owner

Summary

  • Replace 1s battery polling with IOKit power source notifications
  • Replace 5s calendar polling with EKEventStoreChangedNotification
  • Replace 5s WiFi polling with CWEventDelegate (30s for RSSI only)
  • Replace 100ms spaces polling with NSWorkspace notifications
  • Replace Timer with DispatchWorkItem in MenuBarPopup

Test plan

  • App builds successfully
  • App launches and runs
  • Battery widget updates when plugging/unplugging charger
  • Calendar widget updates when adding/modifying events
  • WiFi widget updates when switching networks
  • Spaces widget updates when switching spaces

🤖 Generated with Claude Code

- Battery: use IOPSNotificationCreateRunLoopSource instead of 1s timer
- Calendar: use EKEventStoreChangedNotification instead of 5s timer
- WiFi: use CWEventDelegate for SSID/link changes, reduce RSSI polling to 30s
- Spaces: use NSWorkspace notifications instead of 100ms fallback timer
- MenuBarPopup: use DispatchWorkItem + asyncAfter instead of Timer

This significantly reduces CPU usage and improves power efficiency by
responding to system events rather than continuously polling.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@bottlebrushes bottlebrushes merged commit 6ba00ab into main Jan 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant