Skip to content

feat(core): split tracking for effect and afterRenderEffect#68908

Draft
JeanMeche wants to merge 1 commit into
angular:mainfrom
JeanMeche:split-tracking
Draft

feat(core): split tracking for effect and afterRenderEffect#68908
JeanMeche wants to merge 1 commit into
angular:mainfrom
JeanMeche:split-tracking

Conversation

@JeanMeche
Copy link
Copy Markdown
Member

Mere investigation / WIP:

Introduce a splitTracking helper to separate reactive tracking from non-reactive effect execution by isolating the reactive logic into a dedicated function.

fixes #56155

@angular-robot angular-robot Bot added detected: feature PR contains a feature commit area: core Issues related to the framework runtime labels May 24, 2026
@ngbot ngbot Bot added this to the Backlog milestone May 24, 2026
@JeanMeche
Copy link
Copy Markdown
Member Author

JeanMeche commented May 24, 2026

Usages:

effect:

effect(
  splitTracking(
    () => trackedValue(),
    (val: string, onCleanup: EffectCleanupRegisterFn) => {
      onCleanup(() => ... );
    },
  ),
);

Single phase afterRenderEffect:

afterRenderEffect(
  splitTracking(
    () => trackedValue(),
    (val: string) => {
      untrackedValue();
      effectCount++;
    },
  ),
);

afterRenderEffect with phases

afterRenderEffect({
  earlyRead: () => {
    // early read is tracked
    trackedValue();
    return 42;
  },
  write: splitTracking(
    // tracking fn
    () => trackedValue(),
    (val: string, earlyReadVal: Signal<number>, onCleanup: EffectCleanupRegisterFn) => {
      // non tracking execute fn
      untrackedValue();
      onCleanup(() => { ...  });
    },
  ),
});

@JeanMeche
Copy link
Copy Markdown
Member Author

If we had to compare this PR with #68703, we could argue that a helper function is more versitale to achieve the wanted feature.

Introduce a `splitTracking` helper to separate reactive tracking from non-reactive effect execution by isolating the reactive logic into a dedicated function.

fixes angular#56155
@github-actions
Copy link
Copy Markdown

Deployed adev-preview for 62aeb53 to: https://ng-dev-previews-fw--pr-angular-angular-68908-adev-prev-ew8w3fts.web.app

Note: As new commits are pushed to this pull request, this link is updated after the preview is rebuilt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adev: preview area: core Issues related to the framework runtime detected: feature PR contains a feature commit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Explicit Tracking for effect(): Request for Reconsideration

1 participant