Is there a way to know when blaze finished iteration after session update?

is there a way to know when blaze finished iteration after session update?

I get some info from an external session and store that array into a session var.

In the HTML I have a for each, after that loop is finished, I have to init another javascript library (impress.js)


<template name="ppt_integration">
    <div id="impress">
        {{#each mainTopics }}
<!--         {{level 1}} - {{level 2}}
 -->            <div class="z step slide" data-x="{{XValue @index}}" data-y="-1500">
                <h2 class="ui dividing header" style="margin-left: 160px">{{level 1}} - {{level 2}}
                <div class="ui list" style="margin-left: 175px">
                    {{#each item in itemsOfLevel 3}}
                    <div class="item">


Template.ppt_integration.onRendered(function() {

                Meteor.setTimeout(function() { impress().init(); }, 1000);

    // Tracker.autorun(function() {
    //     var topics = Session.get('integrationTopics');
    //     if (topics) {
    //         console.log('impress initialized, topics');
    //         Meteor.setTimeout(function() { impress().init(); }, 0);
    //     } else {
    //         console.log('wait to init impress, topics not yet loaded');
    //     }
    // })

you see, it works when I put a delay, but if my computer is slow… 1 second is still too slow, and the ui looks crappy…


You could try combining afterflush and defer with something like this:

    Meteor.defer(function(){ // code to execute after Session update

A little ugly if you ask me, but it has worked quite well on many ocassions.

1 Like

Cool! Yeah so maybe i can check also in an tracker when my session object has been filled, and then use Your code to wait for blaze to finish iterating?