Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Request for Public API Access to RxJS Schedulers#7579

kramar started this conversation inIdeas / Feature request
Discussion options

It would be beneficial ifAsapScheduler,AsapAction,AsyncScheduler, andAsyncAction were exposed in the public API. This would help address an inherent problem when using the out-of-the-box RxJSasapScheduler within Angular applications.

Current Behavior

Internally, theAsapScheduler usessetImmediate to schedule actions on the microtask queue. However, it only invokessetImmediate once per microtask tick. Subsequent actions scheduled during the same tick are simply appended to the internal actions array without triggering anothersetImmediate call. All actions are then flushed together during the same tick.

The Problem in Angular Context

This batching behavior can cause critical issues in Angular applications when actions are scheduled from different zone contexts. Specifically:

  1. Zone Context Locking: If actions are scheduled both inside and outside theNgZone during the same microtask tick, the zone context of thefirst scheduled action determines the zone in whichall subsequent actions will execute.

  2. Change Detection Outside NgZone: This becomes particularly problematic when a scheduled action triggers change detection. If that change detection runs outside theNgZone:

    • Components created during that change detection will have their host bindings and event listeners attached outside theNgZone
    • Events emitted from these components will no longer trigger application-level change detection
    • This defeats the core purpose of Angular'sNgZone mechanism

Proposed Solution

To resolve this issue, we need the ability to create separate scheduler instances for different zone contexts:

constasapOutsideNgScheduler:AsapScheduler=newAsapScheduler(AsapAction);

However, this solution requires access to theAsapScheduler andAsapAction classes, which are currently internal to RxJS.

Request

Please consider exposingAsapScheduler,AsapAction,AsyncScheduler, andAsyncAction as part of the public API to enable Angular developers to properly manage zone contexts when using schedulers.

You must be logged in to vote

Replies: 0 comments

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Labels
None yet
1 participant
@kramar

[8]ページ先頭

©2009-2025 Movatter.jp