-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfishbowl.js
35 lines (29 loc) · 845 Bytes
/
fishbowl.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
if(Meteor.isServer) {
Fishbowls = new Meteor.Collection("fishbowls");
Meteor.publish('fishbowl_data', function(){
var self = this;
var handle = Fishbowls.find().observeChanges({
changed : function(id, fields) {
self.changed("fishbowls", id, fields);
}
});
self.onStop(function () {
handle.stop();
});
var record = Fishbowls.findOne();
self.added("fishbowls", record._id, {model: record.model});
self.ready();
});
}
if (Meteor.isClient) {
Fishbowls = new Meteor.Collection("fishbowls");
Meteor.startup(function() {
Session.set('data_loaded', false);
});
Deps.autorun(function() {
Meteor.subscribe('fishbowl_data', function(){
Session.set('data_loaded', true);
});
});
Template.main.isReady = function() { return Session.get('data_loaded'); }
}