AdamBrodzinski / meteor-flux-leaderboard

Flux Example with React & Meteor
131 stars 19 forks source link

Subscription #11

Open SenerDemiral opened 8 years ago

SenerDemiral commented 8 years ago
// Client Main.jsx

shDD = Meteor.subscribe ('DD', null);

Meteor.startup(function() {
  let ddCC = 0;
  Tracker.autorun (function(computation) {
      // Subscription.ready() is reactive.
      if (shDD.ready()) {
        if (computation.firstRun) {
          return;  // ignore first empty run
        }

        ddCC += 1;  // to say something changed
        store.dispatch(Actions.ddChanged(ddCC));
      }
  });
});

// On different times

shDD = Meteor.subscribe ('DD', 'aaaaa');
...
shDD = Meteor.subscribe ('DD', 'bbbbb');
...
shDD = Meteor.subscribe ('DD', 'ccccc');

Tracker listens those 3 subscriptions.! Even handle different. Related records are in minimongo. (Caching like subsManager) Is there something wrong?