Skip to content

Instantly share code, notes, and snippets.

@clyfe
Created July 13, 2011 09:02
Show Gist options
  • Save clyfe/1079954 to your computer and use it in GitHub Desktop.
Save clyfe/1079954 to your computer and use it in GitHub Desktop.
Behavior with state attached VS State with behavior attached
# Behavior with state attached
func = do ->
variable = 0 # state
-> console.log variable++ # behavior
func() # 0
func() # 1
# State with behavior attached
state =
variable: 0 # state
func: -> console.log @variable++ # behavior
state.func() # 0
state.func() # 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment