@js-soft/native-abstractions / Exports / INativeEventBus
Event bus used for sending and receiving messages
▸ init(): Promise
<Result
<void
, ApplicationError
>>
Initialize the event bus. Initially the event bus is in a locked state. Once an AppReadyEvent is fired (usually from outside), the event bus is unlocked. The locked event bus queues published events and publishes them once it is unlocked.
Promise
<Result
<void
, ApplicationError
>>
▸ publish(event
): Result
<void
, ApplicationError
>
Publish a specific event
Name | Type |
---|---|
event |
Event |
Result
<void
, ApplicationError
>
▸ subscribe(event
, handler
): Result
<number
, ApplicationError
>
Subscribe for a handler to be called each time a specific event occurs
Name | Type |
---|---|
event |
Event |
handler |
Function |
Result
<number
, ApplicationError
>
▸ subscribeOnce(event
, handler
): Result
<number
, ApplicationError
>
Subscribe for a handler to be called the next time a specific event occurs
Name | Type |
---|---|
event |
Event |
handler |
Function |
Result
<number
, ApplicationError
>
▸ unsubscribe(id
): Result
<void
, ApplicationError
>
Unsunscribe a handler from being called when a specific event occurs
Name | Type |
---|---|
id |
number |
Result
<void
, ApplicationError
>