Events/B

From CommonJS Spec Wiki
Jump to: navigation, search

STATUS: PROPOSAL

Proposal

Emitter

An emitter internally contains a memo of names to signal objects, which are created on-demand internally.

observe(name String, callback Function) Undefined
gets the internal signal or creates and sets the internal signal for the given name and calls the observe method of that signal with the given callback.
emit(name String, ...args) Undefined
gets the internal signal or creates and sets the internal signal for the given name and applies the emit method of that signal with the given arguments.

Signal

Signal() Signal
creates a signal with an empty observer array.
observe(callback Function) Undefined
pushes the callback on the internal observer array.
emit(...args) Undefined
applies each internal callback in order with the given arguments.