-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
For years, we had a unique external dependency (the only non-dev dependency) called "next-tick" allowing us to schedule callbacks in micro-tasks, either to provide asynchronous browser API shims or for some specific logic where we would prefer to bring some asynchronicity in without the need of bringing the event loop into this. We were not too happy having this dependency because the name "nextTick" didn't ring a bell to most RxPlayer developers who never really worked with node.JS before, whereas the "microtask" concept is generally more known and understood in JavaScript environments, or at least is easier to look for on the internet. Moreover, now that we consider that a Promise object has to be accessible globally in the current environment as a precondition to run the RxPlayer (so IE11 is now only supported as long as `Promise` is polyfilled by the application, which almost everyone still supporting that target in a complex media application does anyway) and that specification-following Promise implementations include a mean to schedule microtasks, we have a very easy way to provide a shim in cases where the `queueMicroTask` global function is not already supported. So this commit removes the next-tick dependency and replace it by either the natively-provided `queueMicroTask` function or a Promise-based ponyfill if not, naming the result `queueMicroTask`, which should be much more familiar to JS dev and is a simpler implementation than what `next-tick` provided, we moreover now control. Its removal also means that now the RxPlayer has no dependency from an application perspective, which may eliminates some groups of issues applications sometimes have when doing weird things with their webpack/vite configs :p We may still have an issue for Promise implementations which do not rely on microtasks (or even event loop events, we shouldn't have an issue with those), but I would expect that the very large majority of Promise polyfills in use today respect that key part of the spec.
- Loading branch information
1 parent
f32197b
commit 8982c7b
Showing
9 changed files
with
16 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
import "../../../src/typings/globals.d"; | ||
import "../../../src/typings/next-tick"; | ||
import "../../../src/typings/object-assign"; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default typeof queueMicrotask === "function" ? | ||
queueMicrotask : | ||
function queueMicrotaskPonyfill( | ||
cb: () => void | ||
): void { | ||
Promise.resolve().then(cb, () => cb()); | ||
}; |