Skip to content

How to use sync controller

  • Runtime setup already integrated in app code.
  • Familiarity with PlaybackSnapshot projection.
  1. Create a controller.
const sync = createLegatoSync({
onSnapshot: (snapshot) => setPlaybackSnapshot(snapshot),
onEvent: (eventName) => console.log('event', eventName),
});
  1. Start sync.
await sync.start();
  1. Read current snapshot when needed.
const current = sync.getCurrent();
  1. Force a resync after app-specific lifecycle transitions.
await sync.resync();
  1. Stop and cleanup.
await sync.stop();

Your app maintains a local playback snapshot that starts from getSnapshot() and updates from subscribed events, with deterministic cleanup on stop.