Re-fire one-shot events in Batman.js
If you use Batman.js as a front-end framework then you know the documentation is horrible. By now you'll also know that the "ready" state on a view is a one-shot event that never gets re-fired, even if the view's HTML or contents are changed out – calling view.fire 'ready' simply does nothing.
Unless you use this undocumented but public reset method resetOneShot:
someView = new Batman.View
# ... snip, but imagine "ready" was already fired ...
someView.fire 'ready' # Does nothing
someView.event('ready').resetOneShot()
someView.fire 'ready' # 'ready' event is fired
The only reasonable way to learn how to actually use Batman.js is to pour through the source code and the tests. Really, the tests are where you'll get some useful information.
Written by Adam Yanalunas
Related protips
2 Responses
This function is now documented :) http://batmanjs.org/docs/api/batman.event.html#prototype_function_resetoneshot
Good looking out. Thanks.
Come downtown sometime and I'll buy you a beer.
Have a fresh tip? Share with Coderwall community!
JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.
Security insights from Cside