Skip to content

Instantly share code, notes, and snippets.

@Dionid
Created October 28, 2015 15:06
Show Gist options
  • Save Dionid/b224363d00cbb011ba95 to your computer and use it in GitHub Desktop.
Save Dionid/b224363d00cbb011ba95 to your computer and use it in GitHub Desktop.
Simple Model example on coffeescript
class ModelTZ
constructor: (@attributes)->
@calls = {}
return @
set: (property, value)->
@attributes[property] = value
@changed(property)
get: (property)->
return @attributes[property]
changed: (name)->
@trigger("change:#{name}")
on: (name, func)->
@calls[name] = func
off: (name)->
delete @calls[name]
trigger: (name)->
@calls[name].call(this)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment