-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.js
51 lines (40 loc) · 916 Bytes
/
common.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//code shared between client and server
Players = new Mongo.Collection("players");
if (Meteor.isServer) {
FastRender.route('/player/:_id', function(params) {
this.subscribe('player', params._id);
});
}
Router.configure({
waitOn: function() {
return Meteor.subscribe('AllPlayers');
}
});
Router.route('/player/:_id', {
name:'player',
fastRender: true,
template: 'leaderboard',
data: function () {
var thePlayer = Players.findOne(this.params._id);
console.log( thePlayer);
return {selectedPlayer: thePlayer};
}
,
action: function() {
if (this.ready())
this.render();
}
});
Router.route('home', {
path: '/',
template: 'leaderboard',
fastRender: true,
action: function() {
if (this.ready()) {
this.render();
}
},
data: function() {
return Players.find ();
},
});