-
Notifications
You must be signed in to change notification settings - Fork 0
/
buzz.js
43 lines (35 loc) · 961 Bytes
/
buzz.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
Buzz = new Mongo.Collection('buzz')
if (Meteor.isClient) {
Meteor.subscribe('buzzez-from-now')
// counter starts at 0
Session.setDefault("counter", 0)
Template.hello.helpers({
counter: function () {
return Session.get("counter")
}
})
Template.hello.events({
'click button': function () {
// increment the counter when button is clicked
Session.set("counter", Session.get("counter") + 1)
Buzz.insert({ createdAt: Date.now()})
}
})
Meteor.startup(function(){
Buzz.find({}).observe({
added:function (doc) {
console.log('BUZZ', doc)
$('body').addClass('buzz')
setTimeout(function () { $('body').removeClass('buzz')}, 500)
if (Meteor.isCordova){
navigator.notification.vibrate(500)
}
}
})
})
}
if (Meteor.isServer) {
Meteor.publish('buzzez-from-now', function () {
return Buzz.find({ createdAt: { $gte: Date.now() }})
})
}