class Firehose

extends EventEmitter

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/12

on(event, listener)

Emitted when the connection is opened.

Parameters

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

Returns

this

on(event, listener)

Emitted when the connection is closed.

Parameters

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

Returns

this

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

this

on(event, listener)

Emitted when an error occurs while handling a message.

Parameters

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

Returns

this

on(event, listener)

Emitted when an error occurs within the websocket.

Parameters

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

Returns

this

on(event, listener)

Emitted when an unknown message is received.

Parameters

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

Returns

this

on(event, listener)

Represents an update of an account's handle, or transition to/from invalid state.

Parameters

event: "handle"
listener: (message: ComAtprotoSyncSubscribeRepos.Handle & { $type: "com.atproto.sync.subscribeRepos#handle"; }) => void

Returns

this

on(event, listener)

Represents an account moving from one PDS instance to another.

Parameters

event: "migrate"
listener: (message: ComAtprotoSyncSubscribeRepos.Migrate & { $type: "com.atproto.sync.subscribeRepos#migrate"; }) => void

Returns

this

on(event, listener)

Indicates that an account has been deleted.

Parameters

event: "tombstone"
listener: (message: ComAtprotoSyncSubscribeRepos.Tombstone & { $type: "com.atproto.sync.subscribeRepos#tombstone"; }) => void

Returns

this

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: ComAtprotoSyncSubscribeRepos.Identity & { $type: "com.atproto.sync.subscribeRepos#identity"; }) => void

Returns

this

on(event, listener)

Represents a commit to a user's repository.

Parameters

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

Returns

this

on(event, listener)

An informational message from the relay.

Parameters

event: "info"
listener: (message: ComAtprotoSyncSubscribeRepos.Info & { $type: "com.atproto.sync.subscribeRepos#info"; }) => void

Returns

this