How to display the good subscription ? Meteor JS -


i got little subscription problem doesn't stop when must.

context:

i have tweets collection, display client publication/subscription process. here publication:

meteor.publish('tweets', function(params) {     return tweets.find({hashtag: params}); }); 

you can see have hashtag sort them, , display tweets specified hastag. here client code subscription:

var sub; template.hashtagpage.rendered = function() {     // hashtag of current page     hashtag = document.getelementbyid('hashtag').innerhtml;      sub = meteor.subscribe('tweets', hashtag); };  template.hashtagpage.destroyed = function(){     sub.stop(); }; 

in template, display every tweets got subscription. same template each page display tweets.

but here problem. when first go page wich display tweets hashtag #first, them without problems. if next go page display tweets hashtag #second, client display tweets hashtag #first , #second.

what i'm thinking

normally, .stop() on subscription supposed remove subscription data client's cache (docs.meteor.com/#meteor_subscribe). don't. i've tried change position of sub.stop(). works when it's on same template function subscription, then, no tweets displayed.

how stop subscription show goods tweets hashtag in client page ?

thanks in advance

use session variable. shouldn't have rerun subscription once it's setup. reactive variables meteor rescue.

template.hashtagpage.rendered = function() { // hashtag of current page meteor.subscribe('tweets', session.get('hashtag')); };

template.hashtagpage.events { 'blur #hashtag': function(event) { session.set('hashtag', event.target.val()); } };

normally i'd put subscription in route (using iron-router) waiton


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -