-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Alternate as options [z@appa 0.3 branch] #84
Comments
Great idea! Very simple to implement and understand, gives a lot of flexibility and choice. I'll give it a try, and think about how it should interact with autoexport/autoimport. Thanks! |
Just realized I didn't define "data" in the original gist, that's corrected. |
OK, I implemented it as you described, the only difference being I'm using the setting value, as the two options are mutually exclusive. So, in default 0.3.0 you receive and send data explicitly. Both the context and the param are references to the object with the zappa API appropriate for the situation: zappa (foo) ->
@get '/': ->
funzo = @query.funzo
funzo += '!'
@render index: {funzo}
# Alternative:
foo.get '/': (bar) ->
funzo = bar.query.funzo
funzo += '!'
bar.render index: {funzo}
@on said: ->
funzo = @data.funzo
funzo += '!'
@broadcast said: {funzo}
@client '/index.js': ->
@connect()
@on welcome: ->
funzo = @data.funzo With the option below, the param becomes the merged collection of input variables, and it will also be sent to templates implicitly: zappa ->
@set databag: 'param'
@get '/': (bar) ->
bar.funzo += '!'
@render 'index'
@on said: (bar) ->
bar.funzo += '!'
@broadcast said: bar
@client '/index.js': ->
@connect()
@on welcome: (bar) ->
funzo = bar.funzo And with this one, the same thing but with the context instead: zappa (foo) ->
foo.set databag: 'context'
foo.get '/': (bar) ->
@funzo += '!'
bar.render 'index'
foo.on said: (bar) ->
@funzo += '!'
bar.broadcast said: {@funzo}
foo.client '/index.js': (fuu) ->
fuu.connect()
fuu.on welcome: ->
funzo = @funzo |
Note: |
Diff: https://gist.github.com/1228579 contains two options:
The text was updated successfully, but these errors were encountered: