Implement RFC #957: Render Aware Scheduler Interface#21493
Draft
NullVoxPopuli-ai-agent wants to merge 1 commit into
Draft
Implement RFC #957: Render Aware Scheduler Interface#21493NullVoxPopuli-ai-agent wants to merge 1 commit into
NullVoxPopuli-ai-agent wants to merge 1 commit into
Conversation
Adds the `@ember/scheduler` package proposed by RFC 0957: - `render`, `layout`, `composite`, `next` and `idle` phase functions, each returning a promise that resolves according to the registered scheduling strategy - `registerStrategy`, for providing the scheduling strategy when defining the Application - `@ember/scheduler/strategy`, the default strategy implementation, which flushes the render/layout/composite phases in order via ordered requestAnimationFrame callbacks within a single frame, prior to paint The deprecations of @ember/runloop and RSVP described by the RFC are left to follow-up work; this is the additive API surface. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or 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
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.
Implements the additive API surface of RFC #957 — Render Aware Scheduler Interface (
0957-modernized-scheduler).What this adds
@ember/schedulerrender(),layout(),composite(),next(),idle()— one function per phase from the RFC, each returning a promise that resolves according to the registered scheduling strategy:registerStrategy(strategy)— registers the strategy (an implementation of the RFC'sStrategyinterface) that the phase functions delegate to, intended to be called once when defining the Application. Per the RFC, the strategy holds no callbacks — it only decides when each phase's promise resolves — so scheduled work keeps its async stack traces and cancellation is handled at the call site.@ember/scheduler/strategyThe default strategy. It models work as belonging to a Frame and flushes the
render→layout→compositewindows in order within a single frame, before the next paint, by registering orderedrequestAnimationFramecallbacks (microtasks — and therefore work awaiting a phase — flush between them). Semantics follow the RFC's examples:renderwhile the render window is flushing resolves within the current window (recursive render)layout/compositeduring their own window) resolves in the next framenext()resolves in a task after the current frame completes;idle()usesrequestIdleCallbackwhere availablerequestAnimationFrame(SSR/FastBoot), phases degrade to FIFO timersWhat this intentionally does not do (yet)
The RFC's migration story — deprecating
@ember/runloop/RSVP, theuse-async-scheduleroptional feature flag, mappingschedule('render'/'afterRender')onto the new interface, and evolving the reactivity system to schedule renders — is left to follow-up PRs. This PR establishes the public interface and default strategy so that exploration can begin, matching the RFC's intent that strategies be swappable.Testing
packages/@ember/scheduler/tests)type-tests/@ember/scheduler-test.ts)tests/docs/expected.cjs🤖 Generated with Claude Code