Iron Router data fires 3 times

若如初见. 提交于 2019-12-06 12:27:46

This is a normal behavior, data like most route methods is run inside a reactive computation.

In your data method you depend on this.ready() which happens to be a reactive data source (it returns the state of the wait list returned by waitOn).

So basically this is what is going on :

  • your data method is declared as a computation and initially runs with this.ready() returning false.
  • the subscription you wait on becomes ready some time in the future so this.ready() now returns true and your data method is rerun.

This is not a problem because data methods are usually not computational heavy (they just return some data that is available locally on the client).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!