class Firehose

Constructor

constructor(options?)

Creates a new Firehose instance.

Parameters

options: FirehoseOptions = {}

Optional configuration.

Properties

relay: string

The relay to connect to.

ws: WebSocket

WebSocket connection to the relay.

cursor: string

The current cursor.

Methods

start()

Opens a WebSocket connection to the relay.

close()

Closes the WebSocket connection.

Overload 1/11

on(event, listener)

Emitted when the connection is opened.

Parameters

event: "open"
listener: () => void

Returns

Unsubscribe

on(event, listener)

Emitted when the connection is closed.

Parameters

event: "close"
listener: (cursor: string) => void

Returns

Unsubscribe

on(event, listener)

Emitted when the websocket reconnects due to not receiving any messages for a period of time. This will only be emitted if the autoReconnect option is true.

Parameters

event: "reconnect"
listener: () => void

Returns

Unsubscribe

on(event, listener)

Emitted when an error occurs while handling a message.

Parameters

event: "error"
listener: ({ cursor: string; error: Error; }) => () => void

Returns

Unsubscribe

on(event, listener)

Emitted when an error occurs within the websocket.

Parameters

event: "websocketError"
listener: ({ cursor: string; error: unknown; }) => () => void

Returns

Unsubscribe

on(event, listener)

Represents a commit to a user's repository.

Parameters

event: "commit"
listener: (message: CommitEvent) => void

Returns

Unsubscribe

on(event, listener)

Updates the repo to a new state, without necessarily including that state on the firehose. Used to recover from broken commit streams, data loss incidents, or in situations where upstream host does not know recent state of the repository.

Parameters

event: "sync"
listener: (message: SyncEvent) => void

Returns

Unsubscribe

on(event, listener)

Represents a change to an account's status on a host (eg, PDS or Relay).

Parameters

event: "account"
listener: (message: AccountEvent) => void

Returns

Unsubscribe

on(event, listener)

Represents a change to an account's identity. Could be an updated handle, signing key, or pds hosting endpoint.

Parameters

event: "identity"
listener: (message: IdentityEvent) => void

Returns

Unsubscribe

on(event, listener)

An informational message from the relay.

Parameters

event: "info"
listener: (message: InfoEvent) => void

Returns

Unsubscribe

on(event, listener)

Emitted when an unknown message is received.

Parameters

event: "unknown"
listener: (message: unknown) => void

Returns

Unsubscribe