12345678910111213141516171819202122232425 |
- // Fonction hypothétique...
- function getFacebookLikeCount() {}
- var currentLikeCount = new ReactiveVar();
- Meteor.setInterval(function () {
- var postId;
- if (Meteor.user() && postId === Session.get('currentPostId')) {
- getFacebookLikeCount(Meteor.user(), Posts.find(postId).url, function (err, count) {
- if (!err) {
- currentLikeCount.set(count);
- }
- });
- }
- }, 5 * 1000);
- // Insert in "post_item.js".
- Template.postItem.helpers({
- likeCount: function () {
- return currentLikeCount.get();
- }
- });
- // Note : similar feature for dictionaries in package "reactive-dict".
|