Publish/Subscribe Plugin for the Sandbox API
Eric Bréchemier © 2011, Some Rights Reserved Legal-Box SAS © 2010-2011, All Rights Reserved
BSD License http://creativecommons.org/licenses/BSD/
2011-08-14
lb. | Publish/Subscribe Plugin for the Sandbox API |
Functions | |
events(sandbox) | Define methods in the ‘events’ property of given sandbox. |
sandbox. | Create a new event subscription, triggering the callback only for events matching the provided filter. |
sandbox. | Remove all subscriptions for given filter. |
sandbox. | Publish a new event for broadcasting to all interested subscribers. |
Create a new event subscription, triggering the callback only for events matching the provided filter.
A new instance of Event Subscriber (lb.core.events.Subscriber) is created and added to the Event publisher (lb.core.events.publisher).
filter | object, the event filter. This object is similar to event objects. Any included property will be used as a filter to restrict events part of the subscription. For example: |
callback | function, the associated callback(event). The event object contains at least the same properties as the filter. In addition, custom properties may be defined by the creator of the event. |
Remove all subscriptions for given filter.
filter | object, an event filter. |
It is not necessary to provide the identical filter project provided in subscribe(); all filters with the same set of properties/values will get the corresponding subscriptions removed.
Publish a new event for broadcasting to all interested subscribers.
event | object, the event to publish. It shall be a valid JSON [1] object: no methods, no circular references. |
[1] Introducing JSON (JavaScript Object Notation) http://www.json.org/