-
Notifications
You must be signed in to change notification settings - Fork 18
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
Batching support #122
Batching support #122
Conversation
Co-authored-by: Omar <Shenato@users.noreply.github.com>
Co-authored-by: Omar <Shenato@users.noreply.github.com>
Making sure to exhaust all tasks before exiting
Needs unit tests
Still needs unit tests (as previous implementation proved to not be sufficient)
Also properly handles exceptions within a batch.
@@ -7,3 +7,4 @@ export * from './helpers' | |||
export * from './hooks' | |||
export * from './mapFacets' | |||
export * from './types' | |||
export { batch } from './scheduler' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remain consistent and export with *
. I know there are other two functions being exported and maybe they were meant as internal, but I think there's value in exposing them, we don't yet know if there is no use for them in third party library code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly, the reason was to keep them private.
The main risk with open-source packages is that once an API is public and used... its a wider surface we need to keep compatible.
The main motivation is to prevent execution of effects with "transient" values. The pseudo-code below explains in a better way a very common scenario when working with Facets:
Batching by default
It changes the default implementation of
createFacet
to automatically start a batch when its updated, so consumers will get the benefit of batching without having to update any of their code.Batching multiple Facets
In addition, it does introduce a new API
batch
, that allows batching together multiple Facet updates.This API was inspired by existing community patterns, such as Solid's batch.
Performance
Benchmarks done in the internal Mojang codebase showed either an improvement or similar performance after this change (backed by the benchmarks in this repository).
Release candidates
To try this out, we've been publishing RCs at batch...batch-rc