Newbie Question: How to make data non-reactive?

Hi guys,

yesterday I heard in the meteor club podcast (@joshowens) that performance-wise NOT all data needs to be reactive.

Out of interest: How do a achieve this?
How do I display a non-reactive datasource?
You you give me some examples?

Kind regards
Barty

Take a look at Tracker.nonreactive() in the documentation. I think all will be explained there.

This can be as simple as:

Template.mytemplate.helpers({
  result: function() {
    return "hello";
  }
});

<template name="mytemplate">
  {{result}}
</template>

To anything more complex that still returns static data. Under the covers, Blaze uses Tracker, and Tracker always runs its enclosed code once (which is why Blaze renders “hello” above). However, if the enclosed code is not reactive, it won’t get run again.

Meteor methods would be an easy way to get data from the server into the UI without reactivity attached in the long run.

I am getting old, I don’t even remember saying anything about that :stuck_out_tongue:

2 Likes

We are using low level publish API to send just initial payload to client and that way it is kinda non-reactive on backend. But I am not sure how it is from server resource point of view.

If you still want subscription synchronized and only non-reactive UI so it does not change without user interaction, you can use Cursor.find with reactive:false on client, so it will not invalidate UI every time minimongo change.