0

I'm using subscriptions manager with iron-router and my problem is this one.

I have a collection "participants" with 2 publications: allParticipants and todayParticipants.

if I go to this page:

Router.map(function () {
    this.route('winners', {
        waitOn: function () {
            return [subs.subscribe('allWinners'),
                subs.subscribe('allParticipants')];
            console.log("subscribed!");


        },
        data: function () {
            return {
                winners: Winners.find(),
                participants: Participants.find(),
                loginBox: "True"
                }

        }
    });

AllParticipants publication is subscribed and put in cache by the subscription manager package.

If after this, I go to this page:

Router.map(function () {
    this.route('participants', {
        path: '/',
        waitOn: function () {
            return subs.subscribe('todayParticipants');
        },
        data: function () {
            return {
                participants: Participants.find()
            }
        }
    });

I'm expecting to subscribe only the todayParticipants but as my subscription is automatically named "Participants", It uses the cached subscription from the previous page being allParticipants.

Is there a way to change the name of my subscriptions in order to have each of them in the right cache?

Thanks.

2 Answers 2

0

What I do in my waitOn function is first stop my subscriptions like

 if (App.subs) {
     for (name in App.subs) {
         App.subs[name].stop();
     }
 }

And then I create new subscriptions

App.subs = {
    settings: Meteor.subscribe('settings', project), 
    ...
};

return [App.sub.settings, .....];

Hope this helps!

3
  • Hi! Sorry to get back to you so lately. If you stop your subscriptions like this, aren't you loosing the advantage of subs? (ie. not having to redownload your subscriptions on each page?). There is not simple way to name your subscriptions accordingly to the publication's name? Thanks.
    – ndemoreau
    Jul 8, 2014 at 10:13
  • I guess you're right. When you stop it, you loose all the data. The subscription manager is the first thing on my todo list!! Jul 12, 2014 at 14:46
  • I was wondering if you found a solution yet ? I'm using the subscription manager too now, and have a similar problem Jul 18, 2014 at 13:41
0

Today, there seems to be no solution to this problem.

More explanation here: https://github.com/meteorhacks/subs-manager/issues/11

What I'm doing now is using a very limited number of subscriptions (filtered mainly on user) and then I create as much data objects as I want filtering my subscriptions in different ways.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.