Last active
August 29, 2015 14:05
-
-
Save cromwellryan/41e23126f8cea5fb6f8d to your computer and use it in GitHub Desktop.
Register and Dispatch Pattern
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
listen_for_clicks = -> | |
$('.clickable').click -> | |
console.debug 'clicked it!' | |
Initializer.register listen_for_clicks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@App = | |
init: -> | |
Initializer.start | |
$ -> | |
App.init() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
started = -> | |
console.debug "We've started!" | |
Initializer.register started |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Initializer = | |
startup_functions: [] | |
register: (func) -> | |
@startup_functions.push func | |
start: -> | |
func() for func in @startup_functions |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://gist.github.com/kuatsure/c6708e9242f4767b2f71