Skip to content

Instantly share code, notes, and snippets.

@cromwellryan
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cromwellryan/41e23126f8cea5fb6f8d to your computer and use it in GitHub Desktop.
Save cromwellryan/41e23126f8cea5fb6f8d to your computer and use it in GitHub Desktop.
Register and Dispatch Pattern
listen_for_clicks = ->
$('.clickable').click ->
console.debug 'clicked it!'
Initializer.register listen_for_clicks
@App =
init: ->
Initializer.start
$ ->
App.init()
started = ->
console.debug "We've started!"
Initializer.register started
@Initializer =
startup_functions: []
register: (func) ->
@startup_functions.push func
start: ->
func() for func in @startup_functions
@kuatsure
Copy link

@yock
Copy link

yock commented Aug 19, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment