channel.publish(message)


新增于: v15.1.0, v14.17.0
  • message <any> 要发送给通道订阅者的消息

    \message <any> The message to send to the channel subscribers

向通道的任何订阅者发布消息。这将同步触发消息处理程序,因此它们将在同一上下文中执行。

\Publish a message to any subscribers to the channel. This will trigger message handlers synchronously so they will execute within the same context.

import diagnostics_channel from 'node:diagnostics_channel';
const channel = diagnostics_channel.channel('my-channel');
channel.publish({
 some: 'message',
});const diagnostics_channel = require('node:diagnostics_channel');
const channel = diagnostics_channel.channel('my-channel');
channel.publish({
 some: 'message',
});

AltStyle によって変換されたページ (->オリジナル) /