Skip to main content
zerotal

Documentation


Documentation / @zerotal/flow / index / presence

Function: presence()

presence(channel): (value, context) => void

Defined in: flow/src/decorators.ts:502

Binds a field to a broadcast presence channel — the framework keeps it filled with the live member list (who's here), updating on join/leave.

Parameters

channel

PresenceChannel

The channel name, or a resolver over the component instance.

Returns

A field decorator that registers the presence binding.

(value, context) => void

Remarks

The channel is resolved per-instance: pass a static string, or a (self) => string resolver for dynamic rooms. The bound prop is server-controlled — like @locked, it is included in the snapshot but is not client-writable. Applies to a field only.

Example

class RoomHeader extends Component {
  @presence((self) => `room.${self.roomId}`)
  members: PresenceMember[] = [];

  @locked roomId = "";
}