From a68f91c884cf1837425861a6abddcdd6ffaa694b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerhard=20St=C3=B6bich?= <18708370+Flarna@users.noreply.github.com> Date: Fri, 24 Sep 2021 13:47:58 +0200 Subject: [PATCH] doc: add version when diagnostics_channel APIs were added MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a yaml section to document when diagnostics_channel APIs were introduced. PR-URL: https://github.com/nodejs/node/pull/40208 Reviewed-By: Stephen Belanger Reviewed-By: Tobias Nießen Reviewed-By: James M Snell Reviewed-By: Colin Ihrig --- doc/api/diagnostics_channel.md | 42 ++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/doc/api/diagnostics_channel.md b/doc/api/diagnostics_channel.md index 8a591da61f43ca..1faa6bee24deb4 100644 --- a/doc/api/diagnostics_channel.md +++ b/doc/api/diagnostics_channel.md @@ -79,6 +79,12 @@ if (channel.hasSubscribers) { #### `diagnostics_channel.hasSubscribers(name)` + + * `name` {string|symbol} The channel name * Returns: {boolean} If there are active subscribers @@ -106,6 +112,12 @@ if (diagnostics_channel.hasSubscribers('my-channel')) { #### `diagnostics_channel.channel(name)` + + * `name` {string|symbol} The channel name * Returns: {Channel} The named channel object @@ -127,6 +139,12 @@ const channel = diagnostics_channel.channel('my-channel'); ### Class: `Channel` + + The class `Channel` represents an individual named channel within the data pipeline. It is use to track subscribers and to publish messages when there are subscribers present. It exists as a separate object to avoid channel @@ -137,6 +155,12 @@ with `new Channel(name)` is not supported. #### `channel.hasSubscribers` + + * Returns: {boolean} If there are active subscribers Check if there are active subscribers to this channel. This is helpful if @@ -167,6 +191,12 @@ if (channel.hasSubscribers) { #### `channel.publish(message)` + + * `message` {any} The message to send to the channel subscribers Publish a message to any subscribers to the channel. This will trigger @@ -194,6 +224,12 @@ channel.publish({ #### `channel.subscribe(onMessage)` + + * `onMessage` {Function} The handler to receive channel messages * `message` {any} The message data * `name` {string|symbol} The name of the channel @@ -224,6 +260,12 @@ channel.subscribe((message, name) => { #### `channel.unsubscribe(onMessage)` + + * `onMessage` {Function} The previous subscribed handler to remove Remove a message handler previously registered to this channel with