-
Notifications
You must be signed in to change notification settings - Fork 2
/
ccd.jsx
51 lines (47 loc) · 1.49 KB
/
ccd.jsx
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
if (Meteor.isClient) {
Comments = new Mongo.Collection('comments');
Categories = new Mongo.Collection('categories');
FlowRouter.route('/blog/:pageId', {
subscriptions: function(params) {
this.register('blogCategories', Meteor.subscribe('categories'));
this.register('currentPost', Meteor.subscribe('post', params.pageId));
this.register('currentComments', Meteor.subscribe('comments', params.pageId));
},
action: function() {
// We render the template with React
React.render(<Page />, document.getElementById('yield'));
}
});
}
if (Meteor.isServer) {
Meteor.publish('categories', function() {
var self = this;
Meteor.defer(function() {
self.added('categories', 'id1', {text: "Cat 1"});
self.added('categories', 'id2', {text: "Cat 2"});
Meteor._sleepForMs(1500);
self.ready();
});
});
Meteor.publish('comments', function() {
var self = this;
Meteor.defer(function() {
self.added('comments', 'id1', {text: "Comment 1"});
Meteor._sleepForMs(200);
self.added('comments', 'id2', {text: "Comment 2"});
Meteor._sleepForMs(200);
self.added('comments', 'id3', {text: "Comment 3"});
Meteor._sleepForMs(200);
self.added('comments', 'id4', {text: "Comment 4"});
Meteor._sleepForMs(200);
self.ready();
});
});
Meteor.publish('post', function() {
var self = this;
Meteor.defer(function() {
Meteor._sleepForMs(500);
self.ready();
});
});
}