Properties:
| Name | Type | Description | 
|---|---|---|
| providerIdentity | InterApplicationBus.Channel~ProviderIdentity | a read-only provider identity | 
Methods
afterAction(middleware) → {void}
Register middleware that fires after the action. This is passed the return value of the action.
Parameters:
| Name | Type | Description | 
|---|---|---|
| middleware | Channel#ChannelClient~Middleware | Function to be executed after invoking the action. | 
- Tutorials:
Returns:
- Type
- void
beforeAction(middleware) → {void}
Register middleware that fires before the action.
Parameters:
| Name | Type | Description | 
|---|---|---|
| middleware | Channel#ChannelClient~Middleware | Function to be executed before invoking the action. | 
- Tutorials:
Returns:
- Type
- void
disconnect() → {Promise.<void>}
Disconnect from the channel.
- Tutorials:
Returns:
- Type
- Promise.<void>
dispatch(action, payload) → {Promise.<any>}
Dispatch the given action to the channel provider. Returns a promise that resolves with the response from the provider for that action.
Parameters:
| Name | Type | Description | 
|---|---|---|
| action | string | Name of the action to be invoked by the channel provider. | 
| payload | * | Payload to be sent along with the action. | 
- Tutorials:
Returns:
- Type
- Promise.<any>
onDisconnection(listener) → {void}
Register a listener that is called on channel disconnection. It is passed the disconnection event of the disconnecting channel.
Parameters:
| Name | Type | Description | 
|---|---|---|
| listener | InterApplicationBus.Channel~ConnectionEvent | 
- Tutorials:
Returns:
- Type
- void
onError(middleware) → {void}
Register an error handler. This is called before responding on any error.
Parameters:
| Name | Type | Description | 
|---|---|---|
| middleware | Channel#ChannelClient~Middleware | Function to be executed in case of an error. | 
- Tutorials:
Returns:
- Type
- void
register(action, listener) → {boolean}
Register an action to be called by the provider of the channel.
Parameters:
| Name | Type | Description | 
|---|---|---|
| action | string | Name of the action to be registered for the channel provider to later invoke. | 
| listener | Channel#ChannelClient~Action | Function representing the action to be taken on a provider dispatch. | 
- Tutorials:
Returns:
- Type
- boolean
remove(action) → {void}
Remove an action by action name.
Parameters:
| Name | Type | Description | 
|---|---|---|
| action | string | Name of the action to be removed. | 
- Tutorials:
Returns:
- Type
- void
setDefaultAction(middleware) → {void}
Sets a default action. This is used any time an action that has not been registered is invoked. Default behavior if not set is to throw an error.
Parameters:
| Name | Type | Description | 
|---|---|---|
| middleware | Channel#ChannelClient~Middleware | Function to be executed when a client invokes an action name that has not been registered. | 
- Tutorials:
Returns:
- Type
- void
Type Definitions
Action(payload, identity)
Channel action callback signature
Parameters:
| Name | Type | Description | 
|---|---|---|
| payload | any | Payload sent along with the message. | 
| identity | Identity | Identity of the sender. | 
Middleware(action, payload, identity)
Middleware function signature
Parameters:
| Name | Type | Description | 
|---|---|---|
| action | string | Action to be invoked. | 
| payload | any | Payload sent along with the message (or error for error middleware). | 
| identity | Identity | Identity of the sender. |