Skip to content

Instantly share code, notes, and snippets.

@brian-mann
Created April 20, 2013 02:57
Show Gist options
  • Save brian-mann/5424544 to your computer and use it in GitHub Desktop.
Save brian-mann/5424544 to your computer and use it in GitHub Desktop.
do (Backbone) ->
_.extend Backbone.Marionette.Application::,
register: (instance, id) ->
@_registry ?= {}
@_registry[id] = instance
unregister: (instance, id) ->
delete @_registry[id]
resetRegistry: ->
oldCount = @getRegistrySize()
for key, controller of @_registry
controller.region.close()
msg = "There were #{oldCount} controllers in the registry, there are now #{@getRegistrySize()}"
if @getRegistrySize() > 0 then console.warn(msg, @_registry) else console.log(msg)
getRegistrySize: ->
_.size @_registry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment