Question: trailpack event "on" and "once"
crash83k opened this issue · 4 comments
crash83k commented
https://github.com/trailsjs/trailpack/blob/master/index.js#L99
I noticed on this line for the on()
method, it's using this.app.once.apply()
. Would this prevent subsequent events from triggering? What's the difference between the on()
method and once()
method?
konstantinzolotarev commented
@crash83k I think it's just a typo
crash83k commented
Ok. Great. ;)
catrielmuller commented
@crash83k the diference is the fuction "on" execute the callback everytime the event is fired, and "once" only execute the callback one time, the subsequent events fired will be ignored.
Example:
on('init', cb)
init -> cb
init -> cb
init -> cb
once('init', cb)
init->cb
init->
init->
init->