const loader = createSyncLoader({ eventStore, pool });
const { status$, events$ } = loader({ relays, filter: { kinds: [1], authors: [pubkey] } });
events$.subscribe((event) => console.log(event));
status$.subscribe((status) => console.log(status));
// Relays from an observable start loading as they are discovered
loader({ relays: user.outboxes$.pipe(defined()), filter });
Creates a SyncLoader that confidently loads a set of events from multiple relays, some of which may support NIP-77 negentropy sync and some of which may not.
For each relay it probes for NIP-77 support and then either:
Calling the loader returns a
status$observable (immediate lifecycle snapshots and progress updates throttled to 250 ms) and anevents$observable (the deduplicated events). Both complete when every relay has finished and an observable relay list has completed. Subscribing to either observable starts a single shared run that writes received events to the store (deduplicated like the other loaders). Astatus$subscriber that joins after the run started replays the latest status snapshot.