unsubscribe()

unsubscribe(subscriptionIdKey[, onEvent])

Unsubscribe subscription from receiving events.

Parameters:

  • subscriptionIdKey. Required. Subscription ID (number) or Key (string), received during .subscribe()

  • onEvent. Published event callback instance to remove, or it can be not specified, in this case all callbacks and subscription will be removed.

Returns promise:

  • Resolved with one hash-table parameter with following attributes:

    • topic

    • requestId

  • Rejected with one of the Errors instances

const f1 = function (data) { console.log('this was event handler for topic') };
await ws.unsubscribe('subscribed.topic', f1);

let defer = ws.unsubscribe('chat.message.received');

Last updated