Constructor Summary
Public Constructor | ||
public |
|
Method Summary
Public Methods | ||
public |
addListener(url: URL, listener: Listener): MsgListener Register listener to receive message when "msg.to === url". |
|
public |
addResponseListener(url: URL, msgId: number, responseListener: Function) Manually add a response listener. |
|
public |
Helper method to bind listeners (in both directions) into other MiniBus target. |
|
public |
postMessage(msg: Message, responseCallback: Function): number Send messages to local listeners, or if not exists to external listeners. |
|
public |
removeAllListenersOf(url: URL) Remove all existent listeners for the URL |
|
public |
removeResponseListener(url: URL, msgId: number) Remove the response listener. |
Public Constructors
public constructor() source
Public Methods
public addListener(url: URL, listener: Listener): MsgListener source
Register listener to receive message when "msg.to === url". Special url "*" for default listener is accepted to intercept all messages.
Params:
Name | Type | Attribute | Description |
url | URL | Address to intercept, tha is in the message "to" |
|
listener | Listener | listener |
Return:
MsgListener | instance of MsgListener |
public addResponseListener(url: URL, msgId: number, responseListener: Function) source
Manually add a response listener. Only one listener per message ID should exist. ATENTION, there is no timeout for this listener. The listener should be removed with a removeResponseListener, failing to do this will result in a unreleased memory problem.
public bind(outUrl: URL, inUrl: URL, target: MiniBus): Bound source
Helper method to bind listeners (in both directions) into other MiniBus target.
Params:
Name | Type | Attribute | Description |
outUrl | URL | Outbound URL, register listener for url in direction "this -> target" |
|
inUrl | URL | Inbound URL, register listener for url in direction "target -> this" |
|
target | MiniBus | The other target MiniBus |
Return:
Bound | an object that contains the properties [thisListener, targetListener] and the unbind method. |
public postMessage(msg: Message, responseCallback: Function): number source
Send messages to local listeners, or if not exists to external listeners. It's has an optional mechanism for automatic management of response handlers. The response handler will be unregistered after receiving the response, or after response timeout (default to 3s).
Params:
Name | Type | Attribute | Description |
msg | Message | Message to send. Message ID is automatically added to the message. |
|
responseCallback | Function | Optional parameter, if the developer what's automatic response management. |
Return:
number | Returns the message ID, in case it should be needed for manual management of the response handler. |
public removeAllListenersOf(url: URL) source
Remove all existent listeners for the URL
Params:
Name | Type | Attribute | Description |
url | URL | Address registered |