Static ReadonlyEVENT_answers a bidirectional message received usage, the client can use this method, to answer an incoming message in a precise manner so that the caller sending the bidirectional message knows how to deal with it this mechanism can be used for global storages where we have one answering entity per channel delivering the requested data, the request can be done asynchronously via promises waiting for answers
binding into rxjs produces a subject which can be used via next calls to send messages on the other hand we
broadcast a message the message contains the channel and the data and some internal bookkeeping data
the channel to broadcast to
the message dot send (for instance 2 iframes within the same parent broker)
register the current broker into a scope defined by wnd
registers a listener on a channel
the channel to register the listeners for
the listener to register
manual unregister function, to unregister as broker from the current scope
unregisters a listener from this channel
the channel to unregister from
the listener to unregister the channel from
central message broker which uses various dom constructs to broadcast messages into subelements
we use the dom event system as transport and iframe and shadow dom mechanisms in a transparent way to pull this off
usage
broker = new Broker(optional rootElement)
defines a message broker within a scope of rootElement (without it is window aka the current isolation level)
broker.registerListener(channel, listener) registers a new listener to the current broker and channel broker.unregisterListener(channel, listener) unregisters the given listener
broker.broadcast(message, optional direction, optional callBrokerListeners) sends a message (channel included in the message object) in a direction (up, down, both) and also optionally calls the listeners on the same broker (default off)
the flow is like up messages are propagated upwards only until it reaches the outer top of the dom downwards, the messages are propagated downwards only both the message is propagated into both directions
Usually messages sent from the same broker are not processed within... however by setting callBrokerListeners to true the listeners on the same broker also are called brokers on the same level will get the message and process it automatically no matter what. That way you can exclude the source from message processing (and it is done that way automatically)
Isolation levels. Usually every isolation level needs its own broker object registering on the outer bounds
aka documents will register on window iframes on the iframe windowObject isolated shadow doms... document