Meteor-Community-Packages / meteor-collection-hooks

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

Use a delay function iside a before update hook #44

Closed Wenape closed 10 years ago

Wenape commented 10 years ago

Is there a way I could use a timer or a delay function inside a before.update hook to delay the actual update method?

I'm firing a dom animation inside the before.update hook which obviously has a certain duration. Returning 'true' on the callback of the animation doesn't work, as the update method is fired before the callback has a chance to run.

The solution I have right now is a really sloppy one. I call the update method I need, go through the hook, fire the animation, return false on the hook (to invalidate the update method). Then, on the callback of the animation I call the initial update method a second time. This time, sending alongside a Session variable to invalidate the conditional and return true. This way, a regular update is fired when the animation is done.

matb33 commented 10 years ago

I have to think more on this but a slightly less sloppy adjustment would be to pass your option via the update's options parameter instead of through a global Session

Wenape commented 10 years ago

Thanks, that would be a much better solution. Can validate on the server as well.

matb33 commented 10 years ago

— Mathieu @matb33

On Fri, Jun 13, 2014 at 11:08 PM, Wenape notifications@github.com wrote:

Closed #44.

Reply to this email directly or view it on GitHub: https://github.com/matb33/meteor-collection-hooks/issues/44#event-131388290

mizzao commented 10 years ago

I don't think this needs to be in the scope of collection-hooks at all; check out the new Blaze animation hooks: https://groups.google.com/forum/#!topic/meteor-core/1kUoG2mcaRw

matb33 commented 10 years ago

@mizzao the new animation hooks are going to revolutionize meteor-built UIs in general... Although I was surprised that the callback doesn't provide a next function for us to call when we want Blaze to continue what it would normally have done. I'd prefer Blaze to be taking care of talking to the DOM! :)

mizzao commented 10 years ago

@matb33 that's a great suggestion...although I'd imagine that the eventual API will be much improved from the current proof-of-concept. It wouldn't be trivial to do to because the end user might be modifying the DOM in ways that the next function wouldn't be able to handle.

matb33 commented 10 years ago

@mizzao yeah, although then I'd expect them not to call next if they decide to mess with the DOM. I should start using it for my.tablotv.com, it has tons of transitions that could use it -- I could provide some useful feedback from real world application

mizzao commented 10 years ago

@matb33 sounds like you should go pitch in, in that thread :)