-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
v4: Remove next-tick dependency #1312
Merged
Merged
Conversation
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
peaBerberian
force-pushed
the
next-v4
branch
from
November 13, 2023 15:21
5ede134
to
1ea2f31
Compare
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.
peaBerberian
force-pushed
the
misc/remove-next-tick-dependency
branch
from
November 13, 2023 15:21
d77a736
to
6443b1d
Compare
Florent-Bouisset
approved these changes
Nov 14, 2023
peaBerberian
added a commit
that referenced
this pull request
Nov 14, 2023
v4: Remove next-tick dependency
peaBerberian
added a commit
that referenced
this pull request
Nov 14, 2023
v4: Remove next-tick dependency
peaBerberian
added a commit
that referenced
this pull request
Nov 23, 2023
v4: Remove next-tick dependency
peaBerberian
added a commit
that referenced
this pull request
Dec 4, 2023
v4: Remove next-tick dependency
peaBerberian
added a commit
that referenced
this pull request
Dec 5, 2023
v4: Remove next-tick dependency
peaBerberian
added a commit
that referenced
this pull request
Dec 5, 2023
v4: Remove next-tick dependency
peaBerberian
added a commit
that referenced
this pull request
Dec 7, 2023
v4: Remove next-tick dependency
peaBerberian
added a commit
that referenced
this pull request
Dec 19, 2023
v4: Remove next-tick dependency
peaBerberian
added a commit
that referenced
this pull request
Dec 20, 2023
v4: Remove next-tick dependency
peaBerberian
added a commit
that referenced
this pull request
Dec 22, 2023
v4: Remove next-tick dependency
peaBerberian
added a commit
that referenced
this pull request
Jan 3, 2024
v4: Remove next-tick dependency
peaBerberian
added a commit
that referenced
this pull request
Jan 3, 2024
v4: Remove next-tick dependency
peaBerberian
added a commit
that referenced
this pull request
Jan 11, 2024
v4: Remove next-tick dependency
peaBerberian
added a commit
that referenced
this pull request
Jan 11, 2024
v4: Remove next-tick dependency
peaBerberian
added a commit
that referenced
this pull request
Jan 15, 2024
v4: Remove next-tick dependency
peaBerberian
added a commit
that referenced
this pull request
Jan 23, 2024
v4: Remove next-tick dependency
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 thequeueMicroTask
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 resultqueueMicroTask
, which should be much more familiar to JS dev and is a simpler implementation than whatnext-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.