78d3c37c02e77731a25f370f9fac264ef51f01a9Luke Smith * Stores the subscriber information to be used when the event fires.
78d3c37c02e77731a25f370f9fac264ef51f01a9Luke Smith * @param {Function} fn The wrapped function to execute.
78d3c37c02e77731a25f370f9fac264ef51f01a9Luke Smith * @param {Object} context The value of the keyword 'this' in the listener.
78d3c37c02e77731a25f370f9fac264ef51f01a9Luke Smith * @param {Array} args* 0..n additional arguments to supply the listener.
78d3c37c02e77731a25f370f9fac264ef51f01a9Luke Smith * @class Subscriber
78d3c37c02e77731a25f370f9fac264ef51f01a9Luke Smith * @constructor
78d3c37c02e77731a25f370f9fac264ef51f01a9Luke Smith * The callback that will be execute when the event fires
78d3c37c02e77731a25f370f9fac264ef51f01a9Luke Smith * This is wrapped by Y.rbind if obj was supplied.
78d3c37c02e77731a25f370f9fac264ef51f01a9Luke Smith * @property fn
78d3c37c02e77731a25f370f9fac264ef51f01a9Luke Smith * @type Function
78d3c37c02e77731a25f370f9fac264ef51f01a9Luke Smith * Optional 'this' keyword for the listener
78d3c37c02e77731a25f370f9fac264ef51f01a9Luke Smith * @property context
78d3c37c02e77731a25f370f9fac264ef51f01a9Luke Smith * @type Object
78d3c37c02e77731a25f370f9fac264ef51f01a9Luke Smith * Unique subscriber id
78d3c37c02e77731a25f370f9fac264ef51f01a9Luke Smith * @property id
78d3c37c02e77731a25f370f9fac264ef51f01a9Luke Smith * @type String
78d3c37c02e77731a25f370f9fac264ef51f01a9Luke Smith * Additional arguments to propagate to the subscriber
78d3c37c02e77731a25f370f9fac264ef51f01a9Luke Smith * @property args
78d3c37c02e77731a25f370f9fac264ef51f01a9Luke Smith * @type Array
78d3c37c02e77731a25f370f9fac264ef51f01a9Luke Smith * Custom events for a given fire transaction.
78d3c37c02e77731a25f370f9fac264ef51f01a9Luke Smith * @property events
78d3c37c02e77731a25f370f9fac264ef51f01a9Luke Smith * @type {EventTarget}
78d3c37c02e77731a25f370f9fac264ef51f01a9Luke Smith // this.events = null;
78d3c37c02e77731a25f370f9fac264ef51f01a9Luke Smith * This listener only reacts to the event once
78d3c37c02e77731a25f370f9fac264ef51f01a9Luke Smith * @property once
78d3c37c02e77731a25f370f9fac264ef51f01a9Luke Smith // this.once = false;
78d3c37c02e77731a25f370f9fac264ef51f01a9Luke Smith delete this.fn;
78d3c37c02e77731a25f370f9fac264ef51f01a9Luke Smith return null;
78d3c37c02e77731a25f370f9fac264ef51f01a9Luke Smith * Executes the subscriber.
78d3c37c02e77731a25f370f9fac264ef51f01a9Luke Smith * @method notify
78d3c37c02e77731a25f370f9fac264ef51f01a9Luke Smith * @param args {Array} Arguments array for the subscriber.
78d3c37c02e77731a25f370f9fac264ef51f01a9Luke Smith * @param ce {CustomEvent} The custom event that sent the notification.
78d3c37c02e77731a25f370f9fac264ef51f01a9Luke Smith var c = this.context,
78d3c37c02e77731a25f370f9fac264ef51f01a9Luke Smith c = (ce.contextFn) ? ce.contextFn() : ce.context;
78d3c37c02e77731a25f370f9fac264ef51f01a9Luke Smith // only catch errors if we will not re-throw them.
78d3c37c02e77731a25f370f9fac264ef51f01a9Luke Smith } catch (e) {
78d3c37c02e77731a25f370f9fac264ef51f01a9Luke Smith * Returns true if the fn and obj match this objects properties.
78d3c37c02e77731a25f370f9fac264ef51f01a9Luke Smith * Used by the unsubscribe method to match the right subscriber.
78d3c37c02e77731a25f370f9fac264ef51f01a9Luke Smith * @method contains
78d3c37c02e77731a25f370f9fac264ef51f01a9Luke Smith * @param {Function} fn the function to execute.
78d3c37c02e77731a25f370f9fac264ef51f01a9Luke Smith * @param {Object} context optional 'this' keyword for the listener.
78d3c37c02e77731a25f370f9fac264ef51f01a9Luke Smith * @return {boolean} true if the supplied arguments match this
78d3c37c02e77731a25f370f9fac264ef51f01a9Luke Smith * subscriber's signature.
78d3c37c02e77731a25f370f9fac264ef51f01a9Luke Smith return ((this.fn == fn) && this.context == context);