seiyria / bootstrap-slider

A slider control for Bootstrap 3 & 4.
http://seiyria.github.io/bootstrap-slider/
Other
3k stars 1.14k forks source link

makes event listener callbacks execute asynchronously #902

Closed rovolution closed 5 years ago

rovolution commented 5 years ago

Background

After diving through our source code and tests, I realized a serious issue...none of our event listeners were executing asynchronously!

Though we were exposing a callback based API, the callbacks were being executed synchronously whenever the private method _trigger() was being executed.

I wrapped the callback invocations in setTimeout() with a timeout of 0 (which cues the callback to be invoked on the next event loop tick) and fixed a bunch of our tests to reflect this.

Pull Requests

Please accompany all pull requests with the following (where appropriate):

jespirit commented 5 years ago

For future reference:

setTimeout() with delay of 0. Under Late timeouts: https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout#Reasons_for_delays_longer_than_specified

rovolution commented 5 years ago

@jespirit Thanks for the review! i updated with feedback. take a glance and let me know if it all looks good.

rovolution commented 5 years ago

@jespirit just removed the changes + removed the default timeout amount of 0 in the unit tests (setTimeout defaults to 0 seconds when a specific timeout is not specified)

rovolution commented 5 years ago

@jespirit feel free to make the changes you want if you don't want me to block you. i probably will not have time to work on this