Skip to content

Instantly share code, notes, and snippets.

@jaredtmartin
Created January 7, 2014 23:53
Show Gist options
  • Save jaredtmartin/8309126 to your computer and use it in GitHub Desktop.
Save jaredtmartin/8309126 to your computer and use it in GitHub Desktop.
Grouping Breaks Reactivity
// collections/assignments.js
Deps.autorun(function(){
Assignments.grouped = {};
var raw_list = Assignments.find().fetch();
for (var i = raw_list.length - 1; i >= 0; i--) {
if (Assignments.grouped[raw_list[i].date] == undefined) {Assignments.grouped[raw_list[i].date]={}};
if (Assignments.grouped[raw_list[i].date][raw_list[i].meetingId] == undefined) {Assignments.grouped[raw_list[i].date][raw_list[i].meetingId]=[]};
Assignments.grouped[raw_list[i].date][raw_list[i].meetingId].push(raw_list[i]);
};
});
// views/assignments.js
Template.assignments.helpers({
meetings: function(){
return Assignments.grouped[Session.get('current_date')];
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment