varid='dosomething'varhandler=function(){}varemitter=Galactic.emitter(scope)emitter.on(id,handler)// register handleremitter.on.handlers{}// contains all registered handlersemitter.off(id)// unregister handleremitter.emit(id, ...data)// emit handleremitter.emit.andNotifyNewHandlers(id, ...data)// emit handler now and immediately ever after
emitter.andNotifyNewHandlers(...)
emitter.on('dosomething',handler)emitter.emit.andNotifyNewHandlers('dosomething', ...data)// the on(...) handler above is emitted nowemitter.on('dosomething',handler)// anything called from now on is emitted immediately