Raiondesu / eventhoven

Event manager that composes events effortlessly 🎵
https://www.npmjs.com/package/eventhoven
MIT License
5 stars 1 forks source link

`once` can be tricked #34

Closed Raiondesu closed 5 years ago

Raiondesu commented 5 years ago

Currently, if you apply once to a very expensive (computationally) handler, and then trigger the event it was subbed to from an async environment twice or more - the handler will still be executed more than once.

This happens because the once function calls unsubscribe after the handler finishes executing. Ideally, once should unsub the handler right at the start of the execution to ensure the actuality of the event-map's state.