@firebolt-js/openrpc
Version:
The Firebolt SDK Code & Doc Generator
58 lines (37 loc) • 2.52 kB
Markdown
To listen to a single instance of a specific event pass the event name as the first parameter:
```typescript
once(event: string, callback: (data: any) => void): Promise<number>
```
The `once` method will only pass the next instance of this event, and then dicard the listener you provided.
Parameters:
| Param | Type | Required | Summary |
| ---------------------- | -------------------- | ------------------------ | ----------------------- |
| `event` | `string` | Yes | The event to listen for, see [Events](
| *callback* | `function` | Yes | A function that will be invoked when the event occurs. |
Promise resolution:
| Type | Description |
|------|-------------|
| `number` | Listener ID to clear the callback method and stop receiving the event, e.g. `${info.title}.clear(id)` |
Callback parameters:
| Param | Type | Required | Summary |
| ---------------------- | -------------------- | ------------------------ | ----------------------- |
| `data` | `any` | Yes | The event data, which depends on which event is firing, see [Events](
To listen to the next instance only of any events from this module pass only a callback, without specifying an event name:
```typescript
once(callback: (event: string, data: any) => void): Promise<number>
```
Parameters:
| Param | Type | Required | Summary |
| ---------------------- | -------------------- | ------------------------ | ----------------------- |
| *callback* | `function` | Yes | A function that will be invoked when the event occurs. The event data depends on which event is firing, see [Events](
Callback parameters:
| Param | Type | Required | Summary |
| ---------------------- | -------------------- | ------------------------ | ----------------------- |
| `event` | `string` | Yes | The event that has occured listen for, see [Events](
| `data` | `any` | Yes | The event data, which depends on which event is firing, see [Events](
Promise resolution:
| Type | Description |
|------|-------------|
| `number` | Listener ID to clear the callback method and stop receiving the event, e.g. `${info.title}.clear(id)` |
See [Listening for events](../../docs/listening-for-events/) for more information and examples.