SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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.
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(src, type)
EventPublisher
with methods add()
,
fire
, et c.
src
type
APE.EventPublisher(src, type)
EventPublisher
with methods add()
,
fire
, et c.
src
type
Method Detail |
---|
EventPublisher add(fp, thisArg)
Function fp
- the callback function that gets called when src[sEvent] is called.
Object thisArg
- the context that the function executes in.
EventPublisher
this;
EventPublisher addAfter(fp, thisArg)
Function:boolean fp
- the callback function that gets called when src[sEvent] is called.
function's returnValue of false returns false to the original call.
Object thisArg
- the context that the function executes in.
EventPublisher
this;
EventPublisher addBefore(fp, thisArg)
Function:boolean fp
- the callback function that gets called when src[sEvent] is called.
function's returnValue proceed false stops the callstack and returns false to the original call.
Object thisArg
- the context that the function executes in.
EventPublisher
this;
fire(payload)
payload
EventPublisher getEvent()
String
- "beforeFire", "afterFire" conveneince.
EventPublisher
this;
Function remove(fp, thisArg)
Function:boolean fp
- the callback function to remove.
Object thisArg
? - the context that the function executes in.
Function
the function that was passed in, or null if not found;
Function removeAfter(fp, thisArg)
Function:boolean fp
- the callback function to remove.
Object thisArg
? - the context that the function executes in.
Function
the function that was passed in, or null if not found (uses remove());
Function removeBefore(fp, thisArg)
Function:boolean fp
- the callback function to remove.
Object thisArg
? - the context that the function executes in.
Function
the function that was passed in, or null if not found (uses remove());
toString()