18 Commits

Author SHA1 Message Date
matt debergalis
44fb1d2150 use findOne() and set initial timestamp on items. 2012-01-30 12:03:18 -08:00
matt debergalis
5e7daaaff3 New Collection API
The new Collection API separates query handles from result sets.  It
allows template iterators to only redraw changed objects instead of
entire result sets.  This implementation also sets the stage for
minimongo indexes and better invalidation performance.

collection.find() now returns a Collection.Query handle.  To retrieve
results we provide these methods on Collection.Query:

Iterators (encouraged way to access results):

 * query.forEach(function (obj) { ... });
 * results = query.map(function (obj) { ... });

Cursor-based retrieval (iterators are built on fetch):

 * docs = query.fetch(maxlen); // return next [maxlen] (all) docs.
 * doc = query.get(skip);      // return next doc, skipping [skip] (0) docs.

Counter:

 * length = query.count(); // number of results in query.

Live queries (replaces findLive):

 * live_handle = query.observe({added: function (obj, idx) { ... },
                                removed: function (id, idx) { ... },
                                changed: function (obj, idx) { ... },
                                moved: function (obj, old_idx, new_idx) { ... }});

Convenience finders:

 * doc = collection.findOne({color: 'red'});
 * doc = collection.findOne(id_val);

On the client, calling forEach(), map(), fetch(), get(), or findOne()
inside an invalidation context will register a dependency on the entire
query result.  Any change to any objects invalidates the context.

Calling count() inside an invalidation context will register a
dependency that only triggers if objects enter or leave the result set.

Calling observe() does not register a dependency.
2012-01-27 20:59:08 -08:00
Nick Martin
0e39cbe5be Replace new occurances of Skybreak with Meteor. 2012-01-18 17:53:21 -08:00
Nick Martin
459dac9cac Merge branch 'master' into meteor
conflicts hand resolved. deftemplate and liveui reverted to master, will re-do later.

Conflicts:
	admin/generate-dev-bundle.sh
	admin/install-s3.sh
	admin/manifest.json
	app/meteor/deploy.js
	app/meteor/meteor.js
	examples/leaderboard/leaderboard.js
	examples/unfinished/azrael/client/azrael.js
	examples/unfinished/azrael/model.js
	packages/liveui/liveui.js
	packages/templating/deftemplate.js
	packages/templating/html_scanner.js
	tests/minimongo/test.html
2012-01-18 16:14:54 -08:00
Nick Martin
cdb50e3cd8 Work around weird IE8/underscore issue. 2012-01-17 18:05:48 -08:00
Nick Martin
9d3d31df6e Rename .skybreak directories. 2012-01-04 21:27:14 -08:00
Nick Martin
ad8adcbc90 Include missed .skybreak directories. 2012-01-04 21:19:52 -08:00
Nick Martin
3faff2de78 perl -pi -e 's/Sky/Meteor/g' **/* 2012-01-04 20:52:46 -08:00
Nick Martin
23cd5b6912 perl -pi -e 's/Skybreak/Meteor/g' **/* 2012-01-04 18:30:25 -08:00
Geoff Schmidt
e31fde7109 todos: idiom cleanups 2011-12-20 03:23:48 -08:00
Geoff Schmidt
d052ca4b20 clean up azrael example 2011-12-19 17:03:26 -08:00
Geoff Schmidt
fabfa902bf renderList reimplemented for documentfragments.
there may be bugs. leaderboard works though
2011-12-19 17:03:26 -08:00
Geoff Schmidt
7cfdfcf0b9 DocumentFragment-based rendering, with GC, draft
leaderboard works
2011-12-19 17:03:26 -08:00
Geoff Schmidt
c13415b818 invalidations accumulate until flushed (or the event loop runs again)
this way, when you use find instead of findLive, liveui doesn't do O(n^2) work when a subscription returns n records (it used to, because it'd render the list with 1 element, then with 2, …, then with n)

flush guarantees that all changes have been committed to the DOM, for your jquerying pleasure

experimental - needs docs
2011-12-19 16:39:28 -08:00
Geoff Schmidt
5d172d0ded rename renderlist 'query' option to 'selector'
for consistency with other APIs
2011-12-09 23:37:50 -08:00
Geoff Schmidt
8543df9649 use Sky.startup in todos 2011-12-09 13:14:01 -08:00
Geoff Schmidt
24692a60f5 rationalize underscore usage slightly 2011-12-08 16:28:47 -08:00
Geoff Schmidt
0599d5198c move examples into main repo 2011-12-07 21:22:47 -08:00