Skip to content

feat: Adaptive sync, dedicated channels, and event notifications#7

Open
matthieup240 wants to merge 5 commits intoMr-Pepe:mainfrom
matthieup240:feat/adaptive-sync-and-realtime-improvements
Open

feat: Adaptive sync, dedicated channels, and event notifications#7
matthieup240 wants to merge 5 commits intoMr-Pepe:mainfrom
matthieup240:feat/adaptive-sync-and-realtime-improvements

Conversation

@matthieup240
Copy link

Summary

This PR introduces several improvements to the sync system:

Features

  1. Adaptive Sync Intervals

    • Battery-efficient sync based on user activity (5s/15s/30s intervals)
    • Immediate sync trigger when changes detected in idle/recent modes
  2. Dedicated Realtime Channels

    • One channel per table instead of shared channel
    • Better error isolation and network handling
  3. Event Notification System

    • Simple ChangeNotifier API for basic use cases
    • Detailed events (onSyncStarted/onSyncCompleted) for advanced scenarios
  4. Safety & Reliability

    • Periodic Drift re-sync every 20 iterations
    • Improved retry logic for failed operations
    • Immediate processing of realtime events

Breaking Changes

None - fully backward compatible

Testing

All existing tests pass. Adaptive sync tested in production app.

matthieup240 and others added 5 commits October 3, 2025 10:53
- Add SyncEvent classes to track sync events (itemReceived, syncStarted, syncCompleted)
- Add optional callbacks to SyncManager constructor (onItemReceived, onSyncStarted, onSyncCompleted)
- Track sync event sources (realtime vs fullSync)
- Emit events when items are received, syncs start/complete
- Add comprehensive documentation and examples in README
- Add tests for sync event notifications
- Backward compatible implementation

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Add intelligent sync interval adjustment based on user activity patterns
to optimize battery consumption while maintaining responsiveness.

Features:
- Adaptive sync modes (active/recent/idle) with variable intervals (5s/15s/30s)
- Immediate sync triggering when changes detected in idle/recent modes
- Periodic safety checks: re-sync from Drift every 20 iterations
- Immediate processing of realtime events for instant UI updates
- Improved retry logic for failed sync operations

Benefits:
- Reduced battery consumption during idle periods (30s interval)
- Maximum responsiveness during active editing (5s interval)
- Data consistency safeguards with periodic Drift re-syncs
- Instant realtime updates without waiting for sync loop
@Mr-Pepe
Copy link
Owner

Mr-Pepe commented Oct 13, 2025

I already didn't find the time to review your last PR and this one is way bigger, so I don't know when I'll find the time to go through it, sorry.

However, thank you very much for the contribution, I can already see that you've added some cool stuff 👍

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.

2 participants