summaryrefslogtreecommitdiffstats
path: root/packages/kadira-flow-router/test/common/fast_render_route.js
blob: d56f1c0664022a59edab060bb525b1bb4c013185 (plain)
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
FastRenderColl = new Mongo.Collection('fast-render-coll');

FlowRouter.route('/the-fast-render-route', {
  subscriptions: function() {
    this.register('data', Meteor.subscribe('fast-render-data'));
  }
});

FlowRouter.route('/the-fast-render-route-params/:id', {
  subscriptions: function(params, queryParams) {
    this.register('data', Meteor.subscribe('fast-render-data-params', params, queryParams));
  }
});

FlowRouter.route('/no-fast-render', {
  subscriptions: function() {
    if(Meteor.isClient) {
      this.register('data', Meteor.subscribe('fast-render-data'));
    }
  }
});

var frGroup = FlowRouter.group({
  prefix: "/fr"
});

frGroup.route("/have-fr", {
  subscriptions: function() {
    this.register('data', Meteor.subscribe('fast-render-data'));
  }
});

if(Meteor.isServer) {
  if(!FastRenderColl.findOne()) {
    FastRenderColl.insert({_id: "one", aa: 10});
    FastRenderColl.insert({_id: "two", aa: 20});
  }

  Meteor.publish('fast-render-data', function() {
    return FastRenderColl.find({}, {sort: {aa: -1}});
  });

  Meteor.publish('fast-render-data-params', function(params, queryParams) {
    var fields = {params: params, queryParams: queryParams};
    this.added('fast-render-coll', 'one', fields);
    this.ready();
  });
}