Created
September 11, 2013 13:24
-
-
Save davidworkman9/6523537 to your computer and use it in GitHub Desktop.
Meteor interval subscription example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(Meteor.isClient) { | |
Meteor.startup(function () { | |
(function () { | |
var oldSubscription; | |
Meteor.setInterval(function () { | |
var subscription; | |
subscription = Meteor.subscribe('random-image', function () { | |
oldSubscription = subscription; | |
}); | |
if(oldSubscription) | |
oldSubscription.stop(); | |
}); | |
})(); | |
}); | |
} | |
if(Meteor.isServer) { | |
Meteor.publish('random-image', function () { | |
var randomQuery = {}; | |
return Images.find(randomQuery); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment