The Message Center provides a persistent mailbox for an individual app. When values in the mailbox are created, updated, or deleted, an event is broadcast to all listeners.
The KONtx message center provides a persist key-based hash table to store messages combined with broadcast events when hash data is added or updated.
Example
Property
|
Property |
Type |
Description |
|---|---|---|
|
eventType |
String |
Event type onBroadcast used to subscribe to the message center hash table. All subscribers to this event will receive broadcast events when values in the message center’s hash table is changed. |
Methods
String eventType();Returns the string onBroadcast used to filter KONtx.messages events from other system events.
void fetch(String key);Retrieves the value associated with the given key from the hash table. Returns null if not found.
void remove(String key);Deletes the value associated with the given key from the hash table. Notifies all event listeners for the given key that the value has been deleted.
void reset();Resets the hash table and list of event listeners to null.
void store(String key, MixedType value);Updates the value associated with the given key in the hash table. Notifies all event listeners for the given key with the new value. The value can be an object, array, or any primitive type.
void Function.prototype.subscribeTo(Object publishingObject, StringOrArray eventTypes, Object bindingScope);Subcribes to the event type String or Array of events defined by the parameter eventTypes, in this case KONtx.messages.eventType, that are owned by the parameter publishingObject, in this case KONtx.messages. The optional parameter bindingScope is used to bind this function to the given scope before subscribing. This method extends the Function.prototype and is used to listen to events from any event publishing object.