Making fast changing reactive data smooth


#1

Hi all,

I’m trying to do this reactive chat thing.

As in like I throttle the input and it updates a collection on the DB for every few milliseconds. So basically what happens is that it’ supposed to display the partial comments to all other users. However, my ‘view’ refreshes in a very strange blinking fashion that looks terrible. Anyone know how to fix this? Or what could be the problem?

Thanks!


Why import when it works without?
#2

This is a problem that kills performance in large apps. Meteor doesn’t have anything in the guide on how to prevent this, but what you can do is make a standalone Tracker.autorun that fetches stuff from a collection, and then in that autorun use setTimeout (or underscores _.debounce) to execute another function that changes a reactive variable after some amount of time, say 2 seconds). Then, have your template rely on that reactive variable, so that your template updates only once every 2 seconds. You can also make a publication on the server side that updates every 2 seconds using a similar technique.