A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/nodejs/node/commit/88539527d5 below:

tracing channel hasSubscribers getter · nodejs/node@8853952 · GitHub

File tree Expand file treeCollapse file tree 2 files changed

+88

-0

lines changed

Filter options

Expand file treeCollapse file tree 2 files changed

+88

-0

lines changed Original file line number Diff line number Diff line change

@@ -977,6 +977,43 @@ channels.asyncStart.bindStore(myStore, (data) => {

977 977

});

978 978

```

979 979 980 +

#### `tracingChannel.hasSubscribers`

981 + 982 +

<!-- YAML

983 +

added:

984 +

- v22.0.0

985 +

- v20.13.0

986 +

-->

987 + 988 +

> Stability: 1 - Experimental

989 + 990 +

* Returns: {boolean} `true` if any of the individual channels has a subscriber,

991 +

`false` if not.

992 + 993 +

This is a helper method available on a [`TracingChannel`][] instance to check if

994 +

any of the [TracingChannel Channels][] have subscribers. A `true` is returned if

995 +

any of them have at least one subscriber, a `false` is returned otherwise.

996 + 997 +

```mjs

998 +

import diagnostics_channel from 'node:diagnostics_channel';

999 + 1000 +

const channels = diagnostics_channel.tracingChannel('my-channel');

1001 + 1002 +

if (channels.hasSubscribers) {

1003 +

// Do something

1004 +

}

1005 +

```

1006 + 1007 +

```cjs

1008 +

const diagnostics_channel = require('node:diagnostics_channel');

1009 + 1010 +

const channels = diagnostics_channel.tracingChannel('my-channel');

1011 + 1012 +

if (channels.hasSubscribers) {

1013 +

// Do something

1014 +

}

1015 +

```

1016 + 980 1017

### TracingChannel Channels

981 1018 982 1019

A TracingChannel is a collection of several diagnostics\_channels representing

Original file line number Diff line number Diff line change

@@ -0,0 +1,51 @@

1 +

'use strict';

2 + 3 +

const common = require('../common');

4 +

const dc = require('diagnostics_channel');

5 +

const assert = require('assert');

6 + 7 +

const handler = common.mustNotCall();

8 + 9 +

{

10 +

const handlers = {

11 +

start: common.mustNotCall()

12 +

};

13 + 14 +

const channel = dc.tracingChannel('test');

15 + 16 +

assert.strictEqual(channel.hasSubscribers, false);

17 + 18 +

channel.subscribe(handlers);

19 +

assert.strictEqual(channel.hasSubscribers, true);

20 + 21 +

channel.unsubscribe(handlers);

22 +

assert.strictEqual(channel.hasSubscribers, false);

23 + 24 +

channel.start.subscribe(handler);

25 +

assert.strictEqual(channel.hasSubscribers, true);

26 + 27 +

channel.start.unsubscribe(handler);

28 +

assert.strictEqual(channel.hasSubscribers, false);

29 +

}

30 + 31 +

{

32 +

const handlers = {

33 +

asyncEnd: common.mustNotCall()

34 +

};

35 + 36 +

const channel = dc.tracingChannel('test');

37 + 38 +

assert.strictEqual(channel.hasSubscribers, false);

39 + 40 +

channel.subscribe(handlers);

41 +

assert.strictEqual(channel.hasSubscribers, true);

42 + 43 +

channel.unsubscribe(handlers);

44 +

assert.strictEqual(channel.hasSubscribers, false);

45 + 46 +

channel.asyncEnd.subscribe(handler);

47 +

assert.strictEqual(channel.hasSubscribers, true);

48 + 49 +

channel.asyncEnd.unsubscribe(handler);

50 +

assert.strictEqual(channel.hasSubscribers, false);

51 +

}

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4