Expand description
Constructors§
§new BaseStrategy<I extends Item>(): BaseStrategy<I>
new BaseStrategy<I extends Item>(): BaseStrategy<I>
Properties§
abstract readonly keys: I["type"][]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): I[]
awarenessUpdate(_update: AwarenessUpdate, _context: SyncContext): I[]
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(_yjsUpdate: Uint8Array, _context: SyncContext): I[]
localEdit(_yjsUpdate: Uint8Array, _context: SyncContext): I[]
A local edit was made to our document. Return items to send that represent this edit.
Source§receive(item: I, context: SyncContext): I[]
receive(item: I, context: SyncContext): I[]
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): I[]
sample(_context: SyncContext): I[]
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.
Convenience base class for strategies.
Often strategies only need to implement a subset of the strategy methods; the other methods are no-ops. You can use this base class to define all these methods as no-ops so you can override only those you need, decluttering your strategy implementation.
You do not have to use this base class: you can always still implement this interface directly as well.