Class: ChannelClient

InterApplicationBus.Channel# ChannelClient

Instance created to enable use of a channel as a client. Allows for communication with the ChannelProvider by invoking an action on the provider via dispatch and to listen for communication from the provider by registering an action via register.

Constructor

Returned by InterApplicationBus.Channel.connect.

Synchronous Methods
Asynchronous Methods
Middleware

Middleware functions receive the following arguments: (action, payload, senderId). The return value of the middleware function will be passed on as the payload from beforeAction, to the action listener, to afterAction unless it is undefined, in which case the original payload is used. Middleware can be used for side effects.

Note: Do not instantiate this class directly.
Returned by InterApplicationBus.Channel.connect.

Methods

afterAction(middleware)

Register middleware that fires after the action. This is passed the return value of the action.

Parameters:
Name Type Description
middleware fin.desktop.InterApplicationBus.Channel#ChannelClient~Middleware

Function to be executed after invoking the action.

Tutorials:

beforeAction(middleware)

Register middleware that fires before the action.

Parameters:
Name Type Description
middleware fin.desktop.InterApplicationBus.Channel#ChannelClient~Middleware

Function to be executed before invoking the action.

Tutorials:

disconnect() → {Promise.<void>}

Disconnect from the channel.

Returns:
Type
Promise.<void>

dispatch(action, payload) → {Promise.<any>}

Dispatch the given 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>

onError(middleware)

Register an error handler. This is called before responding on any error.

Parameters:
Name Type Description
middleware function

Function to be executed in case of an error.

Tutorials:

register(action, listener)

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 Action

Function representing the action to be taken on a provider dispatch.

Tutorials:

remove(action)

Remove an action by action name.

Parameters:
Name Type Description
action string

Name of the action to be removed.

Tutorials:

setDefaultAction(middleware)

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 fin.desktop.InterApplicationBus.Channel#ChannelClient~Middleware

Function to be executed when a client invokes an action name that has not been registered.

Tutorials:

Type Definitions

Action(payload, identity)

Channel action callback signature

Parameters:
Name Type Description
payload *

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 *

Payload sent along with the message.

identity Identity

Identity of the sender.