Skip to content

Commit 0ca00ea

Browse files
HassamSheikhclaude
andcommitted
docs: update README for IsolateSyncEngine API and bump version to 0.1.6
- Add Quick Start example for IsolateSyncEngine with engineFactory pattern - Add IsolateSyncEngine section to API reference with usage note - Renumber Quick Start steps (logout is now step 7) - Update installation version to ^0.1.6 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent aa65ce8 commit 0ca00ea

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

README.md

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Flutter App --> SyncEngine --> Local DB (Drift/SQLite)
5656

5757
```yaml
5858
dependencies:
59-
dynos_sync: ^0.1.5
59+
dynos_sync: ^0.1.6
6060
```
6161
6262
---
@@ -116,7 +116,23 @@ await sync.push('workouts', id, {
116116
}, operation: SyncOperation.patch);
117117
```
118118

119-
### 6. Logout
119+
### 6. Background isolate
120+
121+
```dart
122+
// Dart isolates can't share live DB objects, so pass a factory instead.
123+
final isolateEngine = IsolateSyncEngine(
124+
engineFactory: () => SyncEngine(
125+
local: DriftLocalStore(AppDatabase()),
126+
remote: SupabaseRemoteStore(client: client, userId: () => uid),
127+
queue: DriftQueueStore(AppDatabase()),
128+
timestamps: DriftTimestampStore(AppDatabase()),
129+
tables: ['tasks', 'notes'],
130+
),
131+
);
132+
await isolateEngine.syncAllInBackground();
133+
```
134+
135+
### 7. Logout
120136

121137
```dart
122138
await sync.logout(); // wipes queue, local data, timestamps
@@ -187,6 +203,20 @@ await sync.logout(); // wipes queue, local data, timestamps
187203
| `SyncRemoteException` | Remote returns an error response |
188204
| `SyncDeserializationException` | Failed to parse remote response |
189205

206+
### IsolateSyncEngine
207+
208+
Runs sync in a background isolate to keep the UI thread free.
209+
210+
```dart
211+
IsolateSyncEngine({required SyncEngine Function() engineFactory})
212+
```
213+
214+
| Method | Description |
215+
|---|---|
216+
| `syncAllInBackground()` | Constructs a fresh engine via `engineFactory` inside a background isolate and runs `syncAll()` |
217+
218+
> **Note:** Dart isolates cannot share live database connections. The `engineFactory` is called inside the isolate, so pass a function that creates new store instances (e.g. `DriftLocalStore(AppDatabase())`), not pre-existing ones.
219+
190220
### Store interfaces
191221

192222
Implement these to plug in your database and backend:

0 commit comments

Comments
 (0)