Repository navigation
Conversation
|
Usages:
effect(
splitTracking(
() => trackedValue(),
(val: string, onCleanup: EffectCleanupRegisterFn) => {
onCleanup(() => ... );
},
),
);Single phase afterRenderEffect(
splitTracking(
() => trackedValue(),
(val: string) => {
untrackedValue();
effectCount++;
},
),
);
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(() => { ... });
},
),
}); |
|
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
|
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. |
|
This draft PR is being closed because it has been stale for 28 days and has seen no activity from you. If you'd like to see this change land, you can re-open this PR. Thank you for being an Angular contributor! |
|
What if an effect looked like a resource: effect({
tracked: () => trackedValue(),
untracked: (val: string, onCleanup: EffectCleanupRegisterFn) => {
onCleanup(() => ... );
},
});Maybe this could be an alternative way of writing it alongside the existing one. I'm not a huge fan of "splitTracking" name, sounds like you are tracking different things at once and handling them separately |
|
This pull request has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Mere investigation / WIP:
Introduce a
splitTrackinghelper to separate reactive tracking from non-reactive effect execution by isolating the reactive logic into a dedicated function.fixes #56155