简体   繁体   中英

Angular2 Meteor execute function after data loading

How i can call function after cursor end loading?

on angular component i call data like

    var those = this;
    this.data= dataCollect.find({id: "1"});
    this.data.observe({
      added: function () {
        those.checkCountData();
      },
      changed: function () {
        those.checkCountData();
      },
      removed: function () {
        those.checkCountData();
      }
    });

where checkCountData is summ of property data. But checkCountData call on each row added in progress loading How i can call it one after load and on change\\add\\remove

For 'after load':

You could this.data.fetch() to resolve the cursor's objects, the function is blocking I guess you can directly call checkCountData() after that.

For 'after add/change/remove':

Observe seems fine, you could create a checkCountData with 'add/change/remove' and 'data' argument that does not check/count all, but only does depending on the 'add/change/remove' context.

Regards

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM