meteor - Problems with Iron Router and function computation + template rendering -
i have issue template rendering before subscription received server + computation function calculates necessary data render it. sometimes, works fine , process first subscribes mongodb, renders computevalues()
function , loads template. when try same thing again, template renders before actual data calculated , results in below error:
exception in template helper: typeerror: cannot read property 'length' of undefined
that tells me computevalues()
function ran without getting data subscription, went through empty db , couldn't calculation properly.
here iron:router code:
router.route("/management/bankroll", { subscriptions: function(){ return meteor.subscribe("bank"); }, action: function(){ this.wait(computevalues()); if(this.ready()){ this.layout("bankroll"); } else{ this.layout("loading"); } }, name: "bankroll" });
i tried kinds of hooks onbeforeaction, used .wait()...pretty , behavior still same. 1 instance, upload works , template rendering waits until data pulled it's supposed to, , if try again, compute function runs before subscription received.
i have used waiton subscription , doesn't work either.
it's template renders before computevalues function calculation due not being able retrieve subscription in time. happens more in larger files retrieving subscription takes longer.
anyone know issue is?
Comments
Post a Comment