You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 10, 2020. It is now read-only.
-`options` - type: Object, optional, might contain the following properties:
14
-
-`discover`: type: Boolean - Will use the DHT to find
15
-
16
-
`callback` must follow `function (err, subscription) {}` where Subscription is a Node.js Stream in Object mode, emiting a `data` event for each new message on the subscribed topic.`err` is an error if the operation was not successful.
17
-
18
-
`subscription` has a `.cancel` event in order to cancel the subscription.
12
+
-`topic: string`
13
+
-`options: Object` - (Optional), might contain the following properties:
14
+
-`discover`: type: Boolean - Will use the DHT to find other peers.
15
+
-`handler: (msg) => ()` - Event handler which will be called with a message object everytime one is received. The `msg` has the format `{from: string, seqno: Buffer, data: Buffer, topicCIDs: Array<string>}`.
16
+
-`callback: (Error) => ()` (Optional) Called once the subscription is established.
19
17
20
18
If no `callback` is passed, a [promise][] is returned.
21
19
22
20
> _In the future, topic can also be type of TopicDescriptor (https://github.com/libp2p/pubsub-notes/blob/master/flooding/flooding.proto#L23). However, for now, only strings are supported._
This works like `EventEmitter.removeListener`, as that only the `handler` passed to a `subscribe` call before is removed from listening. The underlying subscription will only be canceled once all listeners for a topic have been removed.
0 commit comments