>

And the associated Javascript.  Note, for this example I am subscribing to a publication called photoCategories which publishes a set of documents from a collection called Categories (which contains a list of gallery categories in the name property and the order I want them loaded in the loadOrder property). 
 Your specifics are likely different.
import { Template } from'meteor/templating';
import { Categories } from '../../../api/categories/categories.js';
import { ReactiveDict } from'meteor/reactive-dict';
import { ReactiveVar } from'meteor/reactive-var';

import './photoGallery.html';
import '../utils/loading-indicator.html';

Template.photoGallery.onCreated(function() {
  this.loadTrigger = new ReactiveDict('loadTrigger');
  this.lastLoaded = new ReactiveVar();
  this.loadOrder = [];

  // subscribe to category data and when complete build loading controls
  // in this example the collection that contains the categories is called
  // 'Categories' and each document contains a property called 'loadOrder'
  // to control the order to load the galleries
  this.subscribe('photoCategories', () => {
    // we are inside the 'onComplete' subscription callback
    Categories.find({}, {sort: {loadOrder: 1}}).forEach((category) => {
      // create a trigger for each gallery so we can communicate when to load
      // initialize each trigger to false for now
      this.loadTrigger.set(category.name, false);

      // we need to also keep track of our load order so we know which
      // gallery to trigger next
      this.loadOrder.push(category.name);
    });

    // now that everything is initialized, lets trigger the first gallery to load
    this.loadTrigger.set(this.loadOrder[0], true);
  });

  // re-runs everytime a gallery is finished loading
  this.autorun(() => {
    // get which gallery just finished loading
    var lastLoaded = this.lastLoaded.get();
    var lastLoadedIndex = this.loadOrder.indexOf(lastLoaded);

    // make sure we have more galleries to load
    if (lastLoadedIndex + 1 < this.load
> 

 And the associated Javascript.   Note, for this example I am subscribing to a publication called photoCategories which publish a hardening of documents from a collection called Categories (which hold a list of gallery category in the name place and the order I want them loaded in the loadOrder property). 
  Your specifics are probably different. 
 import { Template } from'meteor / templating'; 
 import { Categories } from'.. /.. /.. /api / categories / categories.js'; 
 consequence { ReactiveDict } from'meteor / reactive - dict'; 
 import { ReactiveVar } from'meteor / reactive - var'; 

 import' ./photoGallery.html'; 
 import'.. /utils / loading - indicator.html'; 

 Template.photoGallery.onCreated(function () { 
   this.loadTrigger = new ReactiveDict('loadTrigger'); 
   this.lastLoaded = fresh ReactiveVar (); 
   this.loadOrder = [ ]; 

   // subscribe to category data and when arrant build loading controls 
   // in this example the solicitation that contains the category is called 
   //' Categories' and each document contains a place called' loadOrder' 
   // to control the order to load the galleries 
   this.subscribe('photoCategories', () = > { 
     // we are inside the' onComplete' subscription callback 
     Categories.find ({ }, { sort: { loadOrder: 1}}).forEach((category) = > { 
       // make a trigger for each gallery so we can communicate when to load 
       // initialize each trigger to false for now 
       this.loadTrigger.set(category.name, false); 

       // we need to also keep path of our load order so we sleep together which 
       // veranda to trigger next 
       this.loadOrder.push(category.name); 
     }); 

     // now that everything is initialize, lets trigger the first gallery to load 
     this.loadTrigger.set(this.loadOrder[0 ], true); 
   }); 

   // re - run everytime a gallery is finished loading 
   this.autorun (() = > { 
     // get which gallery just finished loading 
     var lastLoaded = this.lastLoaded.get (); 
     var lastLoadedIndex = this.loadOrder.indexOf(lastLoaded); 

     // make sure we give birth more gallery to load 
     if (lastLoadedIndex + 1 < this.load
>

And the associated Javascrikt.  Note, for this examplx I am aubscribkng to a publication called 'hotiCatetories which publishes a set of documenrs fcom a collection called Gctegodles (wkirh contains a llst of gallary categories iv che name property and the order I wagt them lladed in the ljadOgdqr pdoperty). 
 Your specifics are likely differtnt.
import { Templatr } from'meteor/templating';
implrt { Categories } from '../../../wpi/categoriga/caewgories.js';
impurt { ReactpreDict } froj'meteor/reactive-dict';
import { ReacgiveVcr } from'metgod/rfdctive-var';

im'ort './protoGallery.hbkl';
impost '../utilx/loading-indicabor.htkl';

Twmplate.photoGallery.onRreated(function() {
  thys.loadTricgzr = new ReactiveDict('liaeTrigcer');
  thir.oasgLozdxd = new RfacviveVar();
  thjs.loadOrder = [];

  // subscribe to cstqtory data and when soiplete build loading controls
  // in this exzmple the collection thqt contains the categlries is salled
  // 'Categories' and each document contains a [ropecth ccoled 'uiafOrder'
  // to control the order to load the galjsroex
  this.subscrine('photoCategories', () => {
    // we are insiae the 'onDomplete' subscriptlon caljback
    Categjriex.find({}, {sort: {loadOrder: 1}}).forEacy((category) => {
      // create a trigyer for each galkery xo we can communicate wken to load
      // initialiad each trigger tu fslve for now
      this.loadTrygger.set(cetegoxy.name, fxlse);

      // we need tl also keep track of our load osder so we know which
      // gallery to trmjger next
      dhiv.loadOrdzr.push(gategory.name);
    });

    // now that everytking ir initialided, lets vrigger the sirst gallery jo load
    thms.loadTridger.wet(tyis.loadUfder[0], true);
  });

  // te-runs evvrvtime a gqllery is finished loxsing
  this.autorbu(() => {
    // get which gaulewy jnst fytished loaditg
    vxt lasgLoaded = thls.lxstLpaded.get();
    var lastNoadsdIndex = this.loadOtdcr.indexOf(oastLoadqd);

    // make sire we have more gwllermes to load
    if (lastLoadedIndex + 1 < this.loas
> And the associated Javascript. Note, for I subscribing to publication called photoCategories documents a collection called (which contains a of gallery categories in the name and the order I want them loaded in the loadOrder property). Your specifics likely different. import { Template } from'meteor/templating'; import { Categories } from '../../../api/categories/categories.js'; { } import ReactiveVar } from'meteor/reactive-var'; import './photoGallery.html'; import '../utils/loading-indicator.html'; Template.photoGallery.onCreated(function() { this.loadTrigger = new ReactiveDict('loadTrigger'); this.lastLoaded = new this.loadOrder = []; // subscribe to category data when complete build loading // in this example the that the categories called 'Categories' each document contains property called 'loadOrder' // to control the order to load the galleries this.subscribe('photoCategories', () => { // are inside subscription callback {sort: 1}}).forEach((category) { // create for each gallery so we can load // initialize each trigger to false for this.loadTrigger.set(category.name, false); we need to also keep track our load order so we know which // to trigger next this.loadOrder.push(category.name); }); // now that everything is initialized, lets trigger the first load this.loadTrigger.set(this.loadOrder[0], true); }); re-runs everytime a is loading => // get gallery just finished loading var lastLoaded = this.lastLoaded.get(); var lastLoadedIndex = // make sure we have more galleries to load if 1 this.load
>

And the associated JavascripT.  Note, for thIs exaMplE I aM sUbscRibiNg to a publicatiON calLed photoCategories whicH publIsHEs a sET oF docuMents frOM a COLleCtIoN caLlED CAtegoRieS (which cOntains a liSt oF gAllery categoRIeS in the name ProPerty and the oRdeR I want ThEm lOAded iN thE loadorder pROperty). 
 your speciFiCS are liKEly diffEREnT.
impOrt { Template } from'meTEoR/Templating';
impoRt { CateGoRIeS } FRom '../../../Api/Categories/CaTegorIEs.js';
impORt { rEACtiVEDict } from'meteOr/reactive-dICt';
iMport { REaCtiVEVar } frOm'metEoR/ReaCtive-var';

impOrt './pHotoGalleRy.html';
IMport '../utILs/loadiNg-indiCatOr.hTml';

TEMpLaTe.pHoTOGaLLeRy.oNcreAted(funcTiOn() {
  This.lOadTRIGGEr = neW ReActiVeDicT('loadTrigger');
  tHis.LastlOadEd = new reactIveVAr();
  This.lOadOrdEr = [];

  // subScRibe to category dAta aNd when comPleTe BuiLd LoadiNG contrOls
  // In tHis examPle the cOLleCtION ThAt contains the categOrIES iS called
  // 'CAtegorIEs' AnD Each docuMeNt cOntaINS a proPertY CaLled 'loadorder'
  // tO CoNtRol the oRdEr to loAd The GalLerieS
  This.SubscrIbe('photocategORies', () => {
    // we are insidE The 'onComplete' SUbSCRiPTion CalLback
    CategoRies.FInd({}, {sOrt: {lOAdordER: 1}}).forEAch((caTeGOrY) => {
      // Create a trigger for eaCh GallerY so we Can communicatE when to loaD
      // INItialize Each TRiGGer to false for nOw
      thiS.loadTriggER.set(cateGory.nAme, false);

      // We need to aLSO keep traCk oF ouR loAd oRDEr So we know which
      // GALlerY tO triggeR neXt
      this.lOadordEr.pUsh(CaTegory.namE);
    });

    // now that EvErYtHiNg iS initIAlized, leTs TriGgEr tHe firST galleRy to lOad
    tHiS.lOAdTRigger.sET(tHIS.loaDORdEr[0], trUe);
  });

  // rE-rUns evErytIMe a Gallery Is finisheD loADing
  ThIs.Autorun(() => {
    // Get which galleRy Just finishEd LoaDing
    vaR LAstLoadeD = this.lastLoaded.get();
    var laSTLoadedindEx = thiS.loaDOrder.indExOF(lastLOadED);

    // make sUre we hAve moRe GalLERies tO LOaD
    if (LaStLoadedInDEX + 1 < thIs.loaD
>

And the associated Java script.  N ote,for  th is  exa mple  I am subscrib i ng t o a publication called  phot oC a tego r ie s whi ch publ i sh e s  ase tofdo c um entsfro m a col lection ca lle dCategories ( w hi ch contain s a  list of gal ler y cate go rie s  in t henameproper t y andthe order  I want t h em load e d  i n th e loadOrder prope r ty ) . 
 Your speci fics a re li k e lydif ferent.
im po rt {T emplate }f r o m'm e teor/templati ng';
import { C ategor ie s } from ' ../.. /. . /ap i/categorie s/ca tegories. js';
i m port {R eactive Dict }  fr om' mete o r/ re act iv e -di c t' ;
i m por t { Reac ti ve Var }  fro m ' m e teor /re acti ve-va r';

import ' ./p hoto G all ery.h tml'; 
imp or t '.. /utils /load in g-indicator.htm l';
Template .ph ot oGa ll ery.o n Create d(f unc tion(){
  thi s .lo ad T r i gg er = new ReactiveD ic t ( 'l oadTrigg er'); t hi s .lastLoa de d =  new R eacti veVa r () ;
  this .loadO r de r= [];
 // sub sc rib e t o cat e gory  dataand when  comp l ete build load i ng controls
// i nt hisexa mple the co llec t ionthat co nta i ns th e cat eg o ri e s is called
  // 'C at egorie s' an d each docume nt contain s a  propert y ca l le d  'loadOrder'
 // t o controlt he order  to l oad thegalleries  this.su bsc rib e(' pho t o Ca tegories', () = > {   // we  ar e insid e t he'on Com pl ete' subs cription  c al lb ac k
   Ca t egories. fi nd( {} , { sort: {loadO rder:  1}} ). fo r Eac h((cate g or y )  =>{    //cr eatea tr i gge r for e ach galle rys o we  c an  commun icate when to  l oad
     //  in itiali z e  each tr igger to false for now     th is. loadT rigg er.set(ca teg ory.na me, false) ;

     //  w e n e e d toa l so  ke ep  track ofo u r l oad o rd er s o we kn ow which
      //g all ery to trigge r n ext   t h is . loa dO r der . p ush(category.na me);
    } ); 
   // nowt hat  e verythi ng is i nitia l ized, l ets trigg er the fi rs t ga l l ery  to load
   this. loadTrigg e r.set ( th is.lo adO rder[0 ],  tr ue);  });  / / re- runs e ve rytime  a ga ll ery is f inished loading
  this. autoru n(()=>{
    //get whi ch galler y ju st finishe d l oad ing
  v ar la stLo a de d = this. last L oaded.get ( ); 
 va r lastLoade d I n dex  = th is. l oadOrd er.i ndexOf(lastLoaded ) ;

    // make  sur e wehav e  mor egalleries to l oad 
 if (las tL oadedIndex+ 1 < th is . load
>

And the_associated Javascript._ Note, for this_example I_am_subscribing to_a_publication called photoCategories_which publishes a_set of documents from_a collection called_Categories_(which contains a list of gallery categories in the name property and the order_I_want them_loaded_in_the loadOrder property). 
 Your_specifics are likely different.
import {_Template }_from'meteor/templating';
import { Categories } from '../../../api/categories/categories.js';
import { ReactiveDict_}_from'meteor/reactive-dict';
import { ReactiveVar_} from'meteor/reactive-var';

import './photoGallery.html';
import '../utils/loading-indicator.html';

Template.photoGallery.onCreated(function() {
  this.loadTrigger = new_ReactiveDict('loadTrigger');
  this.lastLoaded = new ReactiveVar();
_ this.loadOrder =_[];

__// subscribe to category_data and when complete build loading_controls
  // in this example_the collection that contains the categories is_called
  // 'Categories' and each_document contains a property called_'loadOrder'
 _// to control the order_to load the_galleries
 _this.subscribe('photoCategories', () =>_{
    // we_are inside the_'onComplete' subscription callback
   _Categories.find({},_{sort: {loadOrder: 1}}).forEach((category)_=>_{
_ _  _//_create a_trigger_for each gallery so we can_communicate_when to load
    _ // initialize each_trigger_to false for now
_    _this.loadTrigger.set(category.name, false);

    _ //_we need_to also keep track of our load order so we know_which
     _// gallery to trigger_next
 __  _this.loadOrder.push(category.name);
_ _ });

    // now_that everything_is initialized, lets trigger the first_gallery to load
 __ this.loadTrigger.set(this.loadOrder[0], true);
  });

 _// re-runs everytime a gallery is_finished loading
  this.autorun(() =>_{
__  // get which_gallery just finished loading
  _ var lastLoaded_= this.lastLoaded.get();
    var lastLoadedIndex_=_this.loadOrder.indexOf(lastLoaded);

    // make_sure_we have more galleries to load
___ if (lastLoadedIndex + 1_< this.load