You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi. We often need to track signals only until they reach the desired value. For example, send an analytics event when the page load completes, and don't send any more analytics events when the user loads something inside the page after the initial load.
I suggest adding the trackedIf utility, which will track the signal only up to a certain value.
someCondition=signal(true);isLoading=signal(true);effect(()=>{if(!someCondition()||trackedIf(isLoading,value=>value)){// always track someCondition, track isLoading only if it is truthyreturn;}sendAnalytic();});
Once the signal is untracked, should it be destroyed or cleaned up?
I think it is unnecessary. Because if there are no signals tracked, the effect will not execute at all.
And the common case of using these utilities is to track one or more signals conditionally (not all). So at least one tracked signal should be present.
This is analog of takeWhile, or filter + take(1) operator in rxjs:
Hi. We often need to track signals only until they reach the desired value. For example, send an analytics event when the page load completes, and don't send any more analytics events when the user loads something inside the page after the initial load.
I suggest adding the trackedIf utility, which will track the signal only up to a certain value.
Expected API:
Realization:
The text was updated successfully, but these errors were encountered: