facebook.js 599 B

12345678910111213141516171819202122232425
  1. // Fonction hypothétique...
  2. function getFacebookLikeCount() {}
  3. var currentLikeCount = new ReactiveVar();
  4. Meteor.setInterval(function () {
  5. var postId;
  6. if (Meteor.user() && postId === Session.get('currentPostId')) {
  7. getFacebookLikeCount(Meteor.user(), Posts.find(postId).url, function (err, count) {
  8. if (!err) {
  9. currentLikeCount.set(count);
  10. }
  11. });
  12. }
  13. }, 5 * 1000);
  14. // Insert in "post_item.js".
  15. Template.postItem.helpers({
  16. likeCount: function () {
  17. return currentLikeCount.get();
  18. }
  19. });
  20. // Note : similar feature for dictionaries in package "reactive-dict".