Class SendAllStrategy

Source
Expand description

Send the entire document state whenever there was a local edit.

Larger payloads, but the receiver converges even when earlier sends were lost, since each send carries the whole state. The dirty flag ensures we only sample (and thus send) after an actual edit, not on every flush.

Constructors§

§

new SendAllStrategy(): SendAllStrategy

Properties§

§readonly keys: "update"[]...

The item types this strategy handles.

A combined strategy uses this to route incoming items to the strategy that owns their type.

Methods§

Source§

awarenessUpdate(_update: AwarenessUpdate, _context: SyncContext): UpdateItem[]

Awareness state was updated.

This is the ephemeral application data being modified during editing.

Examples would be cursor moved, peer went online/offline (or a client re-announced that it is still online).

Return items to send that represent this update, or none if the strategy does not deal with awareness.

Source§

localEdit(): UpdateItem[]

A local edit was made to our document. Return items to send that represent this edit.

Source§

merge(items: UpdateItem[]): UpdateItem

Merge items of the same type into a single item.

Source§

receive(item: UpdateItem, context: SyncContext): UpdateItem[]

An item came in from a peer.

Note that items can come in arbitrary order, so each item has to be handled independently.

It can be applied to context. It can also create items to send in reply.

Source§

sample(context: SyncContext): UpdateItem[]

We can create an item that samples our state.

This could mean the entire state is in the resulting item, or it could be an advert of our state in the form of a state vector.

What the sample is and how it is handled or responded to is up to the strategy. The sample is defined by when it is requested: once just before we send an outgoing message. The strategy may also decide it does not need to create a sample.