Meteor-Community-Packages / meteor-collection-hooks

Meteor Collection Hooks
https://atmospherejs.com/matb33/collection-hooks
MIT License
658 stars 90 forks source link

after.insert is async? #226

Closed stefanocudini closed 6 years ago

stefanocudini commented 7 years ago

hi

This is really amazing and useful meteor pkg congrats @matb33 !

I'm using it to perform caching operations for subfields of documents I was wondering if if any Collection.update(...); inside the after.insert callback is an asynchronous operation or Or I have to do this to get this:

Collection.after.insert(function(id){
  Meteor.defer(function(){
   Collection.update(id, {$set: ... });
  })
});
micahalcorn commented 7 years ago

In my experience, the callbacks are synchronous and will block.

zimme commented 6 years ago

Yes, they are sync for now. There is currently a discussion in #229 about this also. Thinking about adding support for returning a promise from a hook and wait for that before continuing on to the actual method.

stefanocudini commented 6 years ago

ok tnk!