BaileysEx.Connection.EventEmitter (baileys_ex v0.1.0-alpha.8)

Copy Markdown View Source

Buffered connection event emitter modeled after Baileys' makeEventBuffer.

Summary

Functions

Signals the emitter to enter buffering mode.

Returns whether the event emitter is currently in buffering mode.

Returns a specification to start this module under a supervisor.

Wraps a function execution in an active event buffer context.

Emit a specific event. Will buffer the event if buffering is currently active.

Manually flushes the buffer if active. Returns true if a flush occurred.

Registers a process handler function for events. Returns an unsubscription function.

Provides seed values used during conditional event flush evaluation.

Starts the EventEmitter.

Registers a tap handler function that processes events before the main dispatch. Returns an unsubscription function.

Types

event()

@type event() ::
  :blocklist_set
  | :blocklist_update
  | :call
  | :chats_delete
  | :chats_lock
  | :chats_update
  | :chats_upsert
  | :connection_update
  | :contacts_update
  | :contacts_upsert
  | :creds_update
  | :dirty_update
  | :group_join_request
  | :group_member_tag_update
  | :group_participants_update
  | :groups_update
  | :groups_upsert
  | :labels_association
  | :labels_edit
  | :lid_mapping_update
  | :message_receipt_update
  | :messages_delete
  | :messages_media_update
  | :messages_reaction
  | :messages_update
  | :messages_upsert
  | :messaging_history_set
  | :newsletter_participants_update
  | :newsletter_reaction
  | :newsletter_settings_update
  | :newsletter_view
  | :presence_update
  | :socket_node
  | :settings_update

Functions

buffer(server)

@spec buffer(GenServer.server()) :: :ok

Signals the emitter to enter buffering mode.

buffering?(server)

@spec buffering?(GenServer.server()) :: boolean()

Returns whether the event emitter is currently in buffering mode.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

create_buffered_function(server, work)

@spec create_buffered_function(GenServer.server(), (-> term())) :: (-> term())

Wraps a function execution in an active event buffer context.

emit(server, event, data)

@spec emit(GenServer.server(), event(), term()) :: :ok

Emit a specific event. Will buffer the event if buffering is currently active.

flush(server)

@spec flush(GenServer.server()) :: boolean()

Manually flushes the buffer if active. Returns true if a flush occurred.

process(server, handler)

@spec process(GenServer.server(), (map() -> term())) :: (-> :ok)

Registers a process handler function for events. Returns an unsubscription function.

seed(server, values)

@spec seed(GenServer.server(), map()) :: :ok

Provides seed values used during conditional event flush evaluation.

start_link(opts \\ [])

@spec start_link(keyword()) :: GenServer.on_start()

Starts the EventEmitter.

tap(server, handler)

@spec tap(GenServer.server(), (map() -> term())) :: (-> :ok)

Registers a tap handler function that processes events before the main dispatch. Returns an unsubscription function.