trailsjs/trailpack

Question: trailpack event "on" and "once"

crash83k opened this issue · 4 comments

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?

@crash83k I think it's just a typo

Ok. Great. ;)

@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->

Fixed in b05e666