Skip to content

Hugos68/svelte-broadcastable

Repository files navigation

svelte-broadcastable

Svelte broadcastable is a store wrapper for the Broadcast Channel API. It syncs any data across a given channel.

unknown_replay_2023.11.25-22.39_Trim.mp4

Usage

You can import the broadcastable store like so:

import { broadcastable } from 'svelte-broadcastable';

You can use the store like this:

const init = 'hello';

const store = broadcastable('my-channel', init);

The API is identical to the svelte writable store except that it adds 1 parameter called name, this will be the name that is used to instantiate the BroadcastChannel, this allows for using multiple channels when sharing state.