facebook.js 499 B

123456789101112131415161718192021222324
  1. // Fonction hypothétique...
  2. function getFacebookLikeCount() {}
  3. currentLikeCount = 0;
  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 = count;
  10. }
  11. });
  12. }
  13. }, 5 * 1000);
  14. // Insert in "post_item.js".
  15. Template.postItem.helpers({
  16. likeCount: function () {
  17. return currentLikeCount;
  18. }
  19. });