Skip to content

Instantly share code, notes, and snippets.

@zampino
Last active August 29, 2015 14:16
Show Gist options
  • Save zampino/373a8d258362117af3ee to your computer and use it in GitHub Desktop.
Save zampino/373a8d258362117af3ee to your computer and use it in GitHub Desktop.
dependencies
class Manager
@injects 'Task', 'Store', '...'
constructor: ->
$http.get('/tasks').success (data)->
# works for nested resources too
Store.tasks.push new Task(item) for item in data
class Store
constructor: ->
@tasks, @themes, @chapters
class Theme
@inject 'Store'
constructor: (raw_data)->
@id = raw_data.id
tasks: ->
@_tasks ||= Store.tasks.findWhere(theme_id: @id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment