Home > SYS_MessageBus > pullAsyncPublic
SYS_MessageBus.pullAsyncPublic() method
Public message bus: pull a message (Promise version)
Signature
typescript
function pullAsyncPublic(topic: string): Promise<any>;1
Parameters
Parameter | Type | Description |
|---|---|---|
topic | string | Theme |
Returns
Promise<any>
The pulled message
Remarks
Only one message can be pulled at a time. You can use await to wait for the message to be pulled
Example
javascript
// 1. 在公共总线发起拉取(Promise 挂起等待消息)
const pending = eda.sys_MessageBus.pullAsyncPublic('嘉立创示例_公共异步拉取');
// 2. 用 pushPublic 投递消息(私有总线的 push 到不了这里)
eda.sys_MessageBus.pushPublic('嘉立创示例_公共异步拉取', '跨扩展结果已就绪');
// 3. await 直接拿到拉到的消息
const message = await pending;
console.log('拉到的公共消息:', message);1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9