RoomReplicator

fun <S : Quilted<S>> RoomReplicator(room: Room, id: String, initial: S, stateSerializer: KSerializer<S>, scope: CoroutineScope, config: QuilterConfig = QuilterConfig()): Quilter<S>

Creates a Quilter over Room.channel(id) in one call.

This is a thin convenience wrapper that eliminates the three-step wiring pattern:

// Before:
Quilter(
replica = ReplicaId(room.selfId.value),
seam = room.channel(channelId),
initial = initial,
messageSerializer = QuiltMessage.serializer(stateSerializer),
scope = scope,
config = config,
)

// After:
RoomReplicator(room, channelId, initial, stateSerializer, scope)

The admit-gating guarantee of Room.channel is preserved unchanged — the underlying us.tractat.kuilt.core.Seam only surfaces admitted peers, so this replicator will never send state to unadmitted peers.

Return

a fully wired Quilter<S> whose Quilter.replica is derived from Room.selfId.

Parameters

room

the Room whose Room.channel provides the admit-gated us.tractat.kuilt.core.Seam.

id

channel identifier passed to Room.channel. Same id on both sides of a 2-peer room maps to the same logical channel.

initial

the starting state (typically the CRDT's zero / empty value).

stateSerializer

a KSerializer for S. The wrapper derives the QuiltMessage envelope serializer internally.

scope

the CoroutineScope for background replication coroutines. In tests pass backgroundScope from kotlinx.coroutines.test.TestScope.

config

optional tuning; defaults to QuilterConfig production defaults.