EphemeralStore is a structure that allows to track the ephemeral state of the peers.
It can be used to synchronize cursor positions, selections, and the names of the peers.
Each entry uses timestamp-based LWW (Last-Write-Wins) for conflict resolution.
If we don't receive a state update from a peer within the timeout, we will remove their state.
The timeout is in milliseconds. This can be used to handle the offline state of a peer.
Example
conststore = newEphemeralStore(); conststore2 = newEphemeralStore(); // Subscribe to local updates store.subscribeLocalUpdates((data)=>{ store2.apply(data); }) // Subscribe to all updates store2.subscribe((event)=>{ console.log("event: ", event); }) // Set a value store.set("key", "value"); // Encode the value constencoded = store.encode("key"); // Apply the encoded value store2.apply(encoded);
EphemeralStore is a structure that allows to track the ephemeral state of the peers.
It can be used to synchronize cursor positions, selections, and the names of the peers. Each entry uses timestamp-based LWW (Last-Write-Wins) for conflict resolution.
If we don't receive a state update from a peer within the timeout, we will remove their state. The timeout is in milliseconds. This can be used to handle the offline state of a peer.
Example