/* This file draws heavily from https://github.com/phoenixframework/phoenix/blob/d344ec0a732ab4ee204215b31de69cf4be72e3bf/assets/js/phoenix/presence.js License: https://github.com/phoenixframework/phoenix/blob/d344ec0a732ab4ee204215b31de69cf4be72e3bf/LICENSE.md */ import PresenceAdapter from './phoenix/presenceAdapter'; export var REALTIME_PRESENCE_LISTEN_EVENTS; (function (REALTIME_PRESENCE_LISTEN_EVENTS) { REALTIME_PRESENCE_LISTEN_EVENTS["SYNC"] = "sync"; REALTIME_PRESENCE_LISTEN_EVENTS["JOIN"] = "join"; REALTIME_PRESENCE_LISTEN_EVENTS["LEAVE"] = "leave"; })(REALTIME_PRESENCE_LISTEN_EVENTS || (REALTIME_PRESENCE_LISTEN_EVENTS = {})); export default class RealtimePresence { get state() { return this.presenceAdapter.state; } /** * Creates a Presence helper that keeps the local presence state in sync with the server. * * @param channel - The realtime channel to bind to. * @param opts - Optional custom event names, e.g. `{ events: { state: 'state', diff: 'diff' } }`. * * @category Realtime * * @example Example for a presence channel * ```ts * const presence = new RealtimePresence(channel) * * channel.on('presence', ({ event, key }) => { * console.log(`Presence ${event} on ${key}`) * }) * ``` */ constructor(channel, opts) { this.channel = channel; this.presenceAdapter = new PresenceAdapter(this.channel.channelAdapter, opts); } } //# sourceMappingURL=RealtimePresence.js.map