MessageBus

Message bus is a program object which shares infrastructure to exchange events (messages) between various view elements both visual and non-visual.

Description

Message bus is created for each view instance. Messages are sent asynchronously that is sender doesn’t get acknowledgement when the message is finally processed. Message exchange within a single instance view doesn’t affect the other view instances.

Each element both visual and non-visual may be a message source and/or be a message subscriber. The time when element will initiate a message sending depends on element working logic. The time when element will process a newly recieved message depends on element. Thus the moment when the message is sent and the moment when its processing is stopped is not determined perhaps the message has never been sent and perhaps will have never been processed). In other words, the only thing that message bus guarantees is delivery to all existing subscribers.

Syntax

new MessageBus(view)

Parameters

Name Type Description
view View Parent view of message bus.

Methods

Name Description
getView Returns parent view.
send Sends a message of a certain type.
subscribe Subscribes to certain type messages.
unsubscribeByType Unsubscribes from certain type messages.