0

Suppose I have a template that fetches an array from the cloud... or something. Then I render each element in that array using another template, like so:

<template name='A'>
  {{> B data=cloudData}} <!-- [{foo:'4142'}, {foo:'af3d'}, ...] -->
</template>

<template name='B'>
  {{#each data}}
    {{> C}}
  {{/each}}
</template>

I expect cloudData to change often. Is Meteor/Blaze smart enough to only re-render the parts of 'data' that change? If not, how can I force Meteor/Blaze to be smart about it in an idiomatic way?

leinaD_natipaC
  • 4,299
  • 5
  • 21
  • 40
  • 1
    From my experience blaze does a pretty good job and only updates the items that change. If you really want full control and are using meteor collections you can setup a client side observer. As items are added and removed you can add and remove the dom elements from a parent container. The oberver documentation can be found here https://docs.meteor.com/api/collections.html#Mongo-Cursor-observeChanges – Derrick Gremillion Feb 20 '20 at 19:47
  • 1
    If you want re-render control on a Template level you should use a reactive data source combined with a tracker's autorun withing the oncreated callback. However a full working solution would require a bit more code on the "cloud" side, meaning some mockup on how you expect external data to be fetched etc. – Jankapunkt Feb 20 '20 at 23:41
  • I second @Jankapunkt opinion where you'd have to use [tracker](https://docs.meteor.com/api/tracker.html) to create a custom reactive data source that you can fine tune instead of directly passing your `cloudData`. – Harry Adel Feb 21 '20 at 16:51

0 Answers0