# Class Presence

Initializes the Presence

#### Param: channel

The Channel

#### Param: opts

The options, for example `{events: {state: "state", diff: "diff"}}`

- Defined in presence.ts:45

##### Index

### Constructors

constructor

### Methods

list
syncDiff
syncState

## Constructors

### constructor

- new Presence(channel: Channel, opts?: PresenceOptions): Presence

  #### Parameters

  - channel: Channel
  - opts: PresenceOptions = {}

  #### Returns Presence

  - Defined in presence.ts:56

## Methods

### `Static` list

- list<T = PresenceState>(
  presences: PresenceMap,
  chooser?: PresenceChooser<T>,
  ): T[]

  Returns the array of presences, with selected metadata.

  #### Type Parameters

  - T = PresenceState

  #### Parameters

  - presences: PresenceMap
  - `Optional` chooser: PresenceChooser<T>

  #### Returns T[]

  - Defined in presence.ts:242

### `Static` syncDiff

- syncDiff(
  state: PresenceMap,
  diff: PresenceDiff,
  onJoin?: PresenceCallback,
  onLeave?: PresenceCallback,
  ): PresenceMap

  Used to sync a diff of presence join and leave events from the server, as they happen. Like `syncState`, `syncDiff` accepts optional `onJoin` and `onLeave` callbacks to react to a user joining or leaving from a device.

  #### Parameters

  - state: PresenceMap
  - diff: PresenceDiff
  - `Optional` onJoin: PresenceCallback
  - `Optional` onLeave: PresenceCallback

  #### Returns PresenceMap

  - Defined in presence.ts:196

### `Static` syncState

- syncState(
  currentState: PresenceMap,
  newState: PresenceMap,
  onJoin?: PresenceCallback,
  onLeave?: PresenceCallback,
  ): PresenceMap

  Used to sync the list of presences on the server with the client's state. An optional `onJoin` and `onLeave` callback can be provided to react to changes in the client's local presences across disconnects and reconnects with the server.

  #### Parameters

  - currentState: PresenceMap
  - newState: PresenceMap
  - `Optional` onJoin: PresenceCallback
  - `Optional` onLeave: PresenceCallback

  #### Returns PresenceMap

  - Defined in presence.ts:144