Subscribes to a single swarm-specific event on the swarm bus service for a specific client, executing a callback when the event matches a filter.
This function sets up a one-time listener for events on the "swarm-bus" topic associated with a given client ID, invoking the provided callback
with the event data when an event is received and passes the filter condition. It is wrapped in beginContext for a clean execution environment
and logs the operation via loggerService. The callback is queued using functools-kit to ensure sequential processing, and the listener
unsubscribes after the first matching event. The function supports a wildcard client ID ("*") for listening to all clients or validates a specific
client session. It returns an unsubscribe function to cancel the listener prematurely.
Throws
If the clientId is not "*" and no active session exists for it.
Example
constunsubscribe = listenSwarmEventOnce( "client-123", (event) =>event.type === "sync", (event) =>console.log(event) ); // Logs the first "sync" swarm event for "client-123" unsubscribe(); // Cancels listener if not yet triggered
Subscribes to a single swarm-specific event on the swarm bus service for a specific client, executing a callback when the event matches a filter.
This function sets up a one-time listener for events on the "swarm-bus" topic associated with a given client ID, invoking the provided callback with the event data when an event is received and passes the filter condition. It is wrapped in
beginContext
for a clean execution environment and logs the operation vialoggerService
. The callback is queued usingfunctools-kit
to ensure sequential processing, and the listener unsubscribes after the first matching event. The function supports a wildcard client ID ("*") for listening to all clients or validates a specific client session. It returns an unsubscribe function to cancel the listener prematurely.Throws
If the
clientId
is not "*" and no active session exists for it.Example