msm082919
msm082919

Reputation: 707

how to know 'each' done or re done in meteor blaze template

each running after onRendered and Tracker.autorun(if foo is binding subscription data context).

so i cant catch thateach` work is when done.

how to know each is work done, or rework and done?

is it unknown?

Below is an example.

<template name="something">
  {{#each foo}}
    <bar>bar</bar>
  {{/each}}
</template>

Upvotes: 0

Views: 23

Answers (1)

Jankapunkt
Jankapunkt

Reputation: 8423

I don't see a real use case for this but you can use a helper here that does not add anything to the render output:

<template name="something">
  {{#each foo}}
    <bar>bar</bar>
    {{isDone @index foo}}
  {{/each}}
</template>
Template.something.helpers({
  isDone(index, arr) {
    if (index === arr.length - 1) {
      // this was the last element
      // to be rendered. do whatever
      // you want here
    }
  }
})

Not that this is not really a best practice and you should think about why you need to know this? If you have performance issues with your rendering you want review your whole template code design and refactor where necessary.

Upvotes: 0

Related Questions