Class APE.EventPublisher

Defined in EventPublisher.js
  • author: Garrett Smith
  • class: APE.EventPublisher can be used for native browser events or custom events.

    For native browser events, use APE.EventPublisher steals the event handler off native elements and creates a callStack. that fires in its place.

    There are two ways to create custom events.

    1. Create a function on the object that fires the "event", then call that function when the event fires (this happens automatically with native events).
    2. Instantiate an EventPublisher using the constructor, then call fire when the callbacks should be run.

    An EventPublisher itself publishes beforeFire and afterFire. This makes it possible to add AOP before advice to the callStack.

    adding before-before advice is possible, but will impair performance. Instead, add multiple beforeAdvice with: publisher.addBefore(fp, thisArg).add(fp2, thisArg);

    There are no beforeEach and afterEach methods; to create advice for each callback would require modification to the registry (see comments below). I have not yet found a real need for this.


  • Constructor Summary
    APE.EventPublisher(src, type)
                creates an EventPublisher with methods add(), fire, et c.
    APE.EventPublisher(src, type)
                creates an EventPublisher with methods add(), fire, et c.
     
    Method Summary
     EventPublisher add(fp, thisArg)
              
     EventPublisher addAfter(fp, thisArg)
               Adds afterAdvice to the callStack.
     EventPublisher addBefore(fp, thisArg)
               Adds beforeAdvice to the callStack.
    fire(payload)
               Fires the event.
     EventPublisher getEvent()
              
     Function remove(fp, thisArg)
               Removes fp from callstack.
     Function removeAfter(fp, thisArg)
               Removes fp from callstack's afterFire.
     Function removeBefore(fp, thisArg)
               Removes fp from callstack's beforeFire.
    toString()
               helpful debugging info
     
    Constructor Detail

    APE.EventPublisher

    APE.EventPublisher(src, type)
    APE.EventPublisher(src, type)

    Method Detail

    add

    EventPublisher add(fp, thisArg)

    addAfter

    EventPublisher addAfter(fp, thisArg)

    addBefore

    EventPublisher addBefore(fp, thisArg)

    fire

    fire(payload)

    getEvent

    EventPublisher getEvent()

    remove

    Function remove(fp, thisArg)

    removeAfter

    Function removeAfter(fp, thisArg)

    removeBefore

    Function removeBefore(fp, thisArg)

    toString

    toString()

    Documentation generated by JsDoc Toolkit 1.4.0 on Sun Aug 17 2008 17:08:27 GMT-0700 (PDT)