Constructor for an Event
salaryEvent = new BreezeEvent("salaryEvent", person);
The name of the event.
The object that will be doing the publication. i.e. the object to which this event is attached.
Function to call when an error occurs during subscription execution. If omitted then subscriber notification failures will be ignored.
The name of this Event
The object doing the publication. i.e. the object to which this event is attached.
remove all subscribers
Publish data for this event.
// Assume 'salaryEvent' is previously constructed Event
salaryEvent.publish( { eventType: "payRaise", amount: 100 });
This event can also be published asychronously
salaryEvent.publish( { eventType: "payRaise", amount: 100 }, true);
And we can add a handler in case the subscriber 'mishandles' the event.
salaryEvent.publish( { eventType: "payRaise", amount: 100 }, true, function(error) {
// do something with the 'error' object
});
Data to publish
(default=false) Whether to publish asynchonously or not.
Function to be called for any errors that occur during publication. If omitted, errors will be eaten.
false if event is disabled; true otherwise.
Publish data for this event asynchronously.
// Assume 'salaryEvent' is previously constructed Event
salaryEvent.publishAsync( { eventType: "payRaise", amount: 100 });
And we can add a handler in case the subscriber 'mishandles' the event.
salaryEvent.publishAsync( { eventType: "payRaise", amount: 100 }, function(error) {
// do something with the 'error' object
});
Data to publish
Function to be called for any errors that occur during publication. If omitted, errors will be eaten.
Subscribe to this event.
// Assume 'salaryEvent' is previously constructed Event
salaryEvent.subscribe(function (eventArgs) {
if (eventArgs.eventType === "payRaise") {
// do something
}
});
There are several built in Breeze events, such as EntityAspect.propertyChanged, EntityAspect.validationErrorsChanged as well.
// Assume order is a preexisting 'order' entity
order.entityAspect.propertyChanged.subscribe(function (pcEvent) {
if ( pcEvent.propertyName === "OrderDate") {
// do something
}
});
{Object} Whatever 'data' was published. This should be documented on the specific event.
This is a key for 'unsubscription'. It can be passed to the 'unsubscribe' method.
Unsubscribe from this event.
// Assume order is a preexisting 'order' entity
let token = order.entityAspect.propertyChanged.subscribe(function (pcEvent) {
// do something
});
// sometime later
order.entityAspect.propertyChanged.unsubscribe(token);
The value returned from the 'subscribe' method may be used to unsubscribe here.
Whether unsubscription occured. This will return false if already unsubscribed or if the key simply cannot be found.
event bubbling - document later.
Enables or disables the named event for an object and all of its children.
BreezeEvent.enable(“propertyChanged”, myEntityManager, false)
will disable all EntityAspect.propertyChanged events within a EntityManager.
BreezeEvent.enable(“propertyChanged”, myEntityManager, true)
will enable all EntityAspect.propertyChanged events within a EntityManager.
BreezeEvent.enable(“propertyChanged”, myEntity.entityAspect, false)
will disable EntityAspect.propertyChanged events for a specific entity.
BreezeEvent.enable(“propertyChanged”, myEntity.entityAspect, null)
will removes any enabling / disabling at the entity aspect level so now any 'Event.enable' calls at the EntityManager level, made either previously or in the future, will control notification.
BreezeEvent.enable(“validationErrorsChanged”, myEntityManager, function(em) {
return em.customTag === “blue”;
})
will either enable or disable myEntityManager based on the current value of a ‘customTag’ property on myEntityManager. Note that this is dynamic, changing the customTag value will cause events to be enabled or disabled immediately.
The name of the event.
A boolean, a null or a function that returns either a boolean or a null.
Returns whether for a specific event and a specific object and its children, notification is enabled or disabled or not set.
BreezeEvent.isEnabled(“propertyChanged”, myEntityManager)
The name of the event.
A null is returned if this value has not been set.
Generated using TypeDoc
Class to support basic event publication and subscription semantics.