collaborate method
CollaborativeSession
collaborate({
- required SyncChannel channel,
- required List<
CollaborativeReacton< reactons,Object?> > - CrdtMergeStrategy<
Object?> ? defaultStrategy,
Creates and starts a CollaborativeSession that synchronizes the
given reactons over the provided channel.
The session begins syncing immediately. It subscribes to local changes on each reacton and listens for remote updates on the channel.
An optional defaultStrategy is provided for reactons that do not
specify their own CrdtMergeStrategy (defaults to LastWriterWins).
Returns the CollaborativeSession for monitoring status, conflicts, and disconnection.
final session = store.collaborate(
channel: webSocketChannel,
reactons: [counter, tags, config],
defaultStrategy: LastWriterWins(),
);
Implementation
CollaborativeSession collaborate({
required SyncChannel channel,
required List<CollaborativeReacton<Object?>> reactons,
CrdtMergeStrategy<Object?>? defaultStrategy,
}) {
// Ensure all reactons are initialized in the store
for (final reacton in reactons) {
get(reacton);
}
final session = CollaborativeSession._(
store: this,
channel: channel,
);
session._start(reactons, defaultStrategy: defaultStrategy);
_getSessions().add(session);
return session;
}