Skip to content

Instantly share code, notes, and snippets.

@nborwankar
Created August 13, 2010 01:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nborwankar/522102 to your computer and use it in GitHub Desktop.
Save nborwankar/522102 to your computer and use it in GitHub Desktop.
Transcript of skype chat between Nitin Borwankar and J Chris Anderson
Nitin Borwankar: So big picture question that helps me understand why I should spend time grokking evently - two part question
Nitin Borwankar: a) why did you feel the need to create yet another framework b) what can I do with evently I couldn't do with
jQuery events etc?
Chris Anderson: evently was a natural consequence of using jquery
Chris Anderson: it just wraps up all the repetitive crap I kept doing in jquery, and does it automatically
Chris Anderson: so b) nothing
Nitin Borwankar: ok cool
Nitin Borwankar: second q
Chris Anderson: I think evently was discovered not invented
Nitin Borwankar: what are the component files of an evently minimal app (there's too much in a couchapp to tell what's essential
and what not)
Nitin Borwankar: dont need names just functional desc
Chris Anderson: here's some docs that might help show how evently is just a way to write jquery
http://couchapp.couchone.com/docs/_design/docs/index.html#/topic/evently
Chris Anderson: basically, you need jquery.evently.js, which requires jquery.mustache.js
Chris Anderson: if you want to be couchdb aware, you need jquery.couch.app.js
Nitin Borwankar: third q - can evently be used outside couchapp
Nitin Borwankar: I think yes
Chris Anderson: totally
Chris Anderson: there are some features, like queries and changes, that would be dead weight
Chris Anderson: but everything else is server agnostic, and just a style of jquery
Nitin Borwankar: ok this plus the docs should get me started - also it's basically only for event driven apps right or not?
Chris Anderson: basically it's Mustache templated jquery widgets
Chris Anderson: yes, the events can be anything from clicks to _changes
Chris Anderson: and there is _init which runs without anything happening
Chris Anderson: also, you can have custom events, like loggedIn, and trigger them by hand
Chris Anderson: but it is nothing jquery doesn't do all the time anyway
Nitin Borwankar: for instance how would I use it to create a CRUD scaffold like Rails ?
just use it to bind DOM events to js code ?
Nitin Borwankar: I meant a CRUD scaffold for couch
Chris Anderson: $("#foo").evently(javascript_variable_that_has_event_names, app)
Chris Anderson: where app is the app passed by jquery.couch.app.js
Chris Anderson: here's and example
Chris Anderson: http://github.com/jchris/proto/blob/master/_attachments/index.html#L23
Chris Anderson: so that line, waits for couchapp to load the app code from the server (line 22) and then
passes it to evently, so evently has an object it can use to query the server
Nitin Borwankar: yeah that's the new blank couchapp code right?
Chris Anderson: yeah
Chris Anderson: evently then uses the name "account" to load code from the app object that got passed to it
Chris Anderson: that code is here
Chris Anderson: http://github.com/jchris/proto/tree/master/vendor/couchapp/evently/account/
Chris Anderson: evently knows to look in app.ddoc.evently[name] as well as app.ddoc.vendor[**].evently[name]
Chris Anderson: does that make sense?
Nitin Borwankar: ok so where does the actual app object get passed
ie where does the closure - function(app){...} - get *invoked*
Chris Anderson: where name is "account"
Chris Anderson: back to the first code I linked
Chris Anderson: $.couch.app gets passed the closure, and it runs it using jquery's onload
Chris Anderson: so first thing it does is GET the ddoc from couchdb (based on the index.html URL)
Chris Anderson: and then attaches it to app as app.ddoc
Chris Anderson: and then calls the closure with app
Chris Anderson: app also has app.db, app.view() etc
Chris Anderson: importantly it has app.require() which you can use to load the same commonjs modules
as used by show and list functions
Nitin Borwankar: ok cool that was the lifecycle init part that I was missing
Chris Anderson: there is some legacy junk in app that I want to remove
Chris Anderson: http://couchapp.org/page/roadmap#/
Nitin Borwankar: ok, cool all this is under "proto" in github right?
Chris Anderson: yes or `couchapp generate` if you have a newer couchapp version
Chris Anderson: sudo easy_install -U couchapp
Chris Anderson: `couchapp generate myapp
Links:
http://couchapp.couchone.com/docs/_design/docs/index.html#/topic/evently
http://github.com/jchris/proto/blob/master/_attachments/index.html#L23
http://github.com/jchris/proto/tree/master/vendor/couchapp/evently/account/
http://couchapp.org/page/roadmap#/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment