How to use sync controller
Prerequisites
Section titled “Prerequisites”- Runtime setup already integrated in app code.
- Familiarity with
PlaybackSnapshotprojection.
- Create a controller.
const sync = createLegatoSync({ onSnapshot: (snapshot) => setPlaybackSnapshot(snapshot), onEvent: (eventName) => console.log('event', eventName),});- Start sync.
await sync.start();- Read current snapshot when needed.
const current = sync.getCurrent();- Force a resync after app-specific lifecycle transitions.
await sync.resync();- Stop and cleanup.
await sync.stop();Expected Result
Section titled “Expected Result”Your app maintains a local playback snapshot that starts from getSnapshot() and updates from subscribed events, with deterministic cleanup on stop.