Pause updates to clients?


#1

Hey guys,

so we have a long running server side process that inserts/updates a lot of data. It seems it’s sending one frame for each update to each client after each and every insert and update. Is there a way to disable updates to clients till the operation is completed and then send them all at once? Or something like pausing a subscription on all clients that subscribe to affected rows and then resuming that subscription?

Thanks,
Stefan


Pausing or debouncing subscription updates at server
#2

I have seen the following somewhere (can’t find the original reference, unfortunately). It basically uses a reactive session variable to manage the reactivity of a template helper:

Template.name.helpers({
    helperName: function () {
        var reactive = Session.get('reactivity');
        return Collection.find({}, {reactive:reactive});
    }
});

So, the “before” action is Session.set('reactivity', false);. Then you do your long running thing, then do Session.set('reactivity', true); to enable normal template reactivity.

Of course, Session is not available on the server, but you could wrap a Meteor.call up in the setting:

Session.set('reactivity', false);
Meteor.call('longRunningThing', function(err, result) {
  Session.set('reactivity', true);
  ... more stuff ...
});