Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Where should I declare the subscription/s? #70

Open
lobosan opened this issue Feb 4, 2016 · 2 comments
Open

Where should I declare the subscription/s? #70

lobosan opened this issue Feb 4, 2016 · 2 comments

Comments

@lobosan
Copy link

lobosan commented Feb 4, 2016

Dear Arunoda,

I'm working with FlowRouter and I'm declaring one instance of SubsManager() per collection in the file client/helpers/flow-router like this:

DPASubs = new SubsManager();
OrganizacionesSubs = new SubsManager();
CialcosSubs = new SubsManager();
UsersSubs = new SubsManager();
InviteSubs = new SubsManager();
InvitationsSubs = new SubsManager();

An example of how I'm using these instances in a template is:

Template.nuevoProductor.onCreated(function () {
  let self = this;
  self.ready = new ReactiveVar();
  self.autorun(function() {
    let handleDPA = DPASubs.subscribe('dpa');
    let handleOrganizaciones = OrganizacionesSubs.subscribe('organizaciones');
    let handleCialcos = CialcosSubs.subscribe('cialcos');
    self.ready.set(handleDPA.ready());
    self.ready.set(handleOrganizaciones.ready());
    self.ready.set(handleCialcos.ready());
  });
});

So my questions are:

  1. Do I need an instance of SubsManager for each collection? or only one global instance?
  2. Where should I declare this/these instance/s of SubsManager?
@pdiniz13
Copy link
Contributor

I would also like to know the answer to this, since they both seem to have worked.

@arunoda
Copy link
Contributor

arunoda commented Feb 28, 2016

1.Do I need an instance of SubsManager for each collection? or only one global instance?

It's upto you. Think like this. If used a one, all the publications are cached like the same. So, try to keep up with the cacheOptions. (Specially the cacheLimit option)

Other case is the invalidation. If used one, it any subscription added to the cache. All other places uses sub.ready() will re-run. It may cause some perf issues.

2.Where should I declare this/these instance/s of SubsManager?

May be in the same place as you declare collections.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants