Home > SYS_MessageBus > pullAsync
SYS_MessageBus.pullAsync() method
Private message bus: pull a message (Promise version)
Signature
typescript
function pullAsync(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.pullAsync('嘉立创示例_异步拉取');
// 2. 推送消息,挂起的 Promise 随即满足
eda.sys_MessageBus.push('嘉立创示例_异步拉取', { task: '导出 BOM', done: true });
// 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