constructor has an optional root element and an internal name
Static
Readonly
EVENT_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
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)
registers a listener on a channel
idea... a bidirectional broadcast sends a message and waits for the first answer coming in from one of the receivers sending the message back with a messageIdentifier_broadCastId answer
unregisters a listener from this channel
Generated using TypeDoc
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