Meteor-Community-Packages / meteor-collection-hooks

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

Any documentation/info on handling async? #193

Closed zcrowe closed 7 years ago

zcrowe commented 8 years ago

I'm trying to delete a file from Amazon s3 just before a collection item containing a reference item to it is removed from a collection.

I'm using: https://github.com/Lepozepo/S3 to handle the s3 side.

What's the best way to handle the async aspect of dealing the file within the hook: Collection.before.remove(function (userId, doc) {}

Any pointers much appreciated :)

namirsab commented 7 years ago

Just call your async code in the hook. If you want to be sure that the doc is removed, do it in an after hook