platform icon indicating copy to clipboard operation
platform copied to clipboard

untracked for all methods?

Open manfredsteyer opened this issue 1 year ago • 4 comments

Which @ngrx/* package(s) are relevant/related to the feature request?

signals

Information

Angular is starting to untrack certain things by default: https://github.com/angular/angular/pull/54614

Since 17.1.1, Signal Store does the same for rxMethods. Should we also consider this for all other methods provided by the Signal Store? Normally, I don't want such Methods to get the caller's reactive context.

Describe any alternatives/workarounds you're currently using

a) Calling untracked by hand b) Using toObservable (which does the same as a) underneath the covers)

I would be willing to submit a PR to fix this issue

  • [ ] Yes
  • [X] No

manfredsteyer avatar Feb 28 '24 02:02 manfredsteyer

What if we move the untracked from rxMethod to patchState? It is a simple switch but would remove a lot of headaches.

rainerhahnekamp avatar Feb 29 '24 12:02 rainerhahnekamp

Would this be a breaking change?

brandonroberts avatar Mar 06 '24 14:03 brandonroberts

If I write code that relies on the runtime error being thrown, it could be a breaking change. But I see it is extremely rare to have such code...

In the best case, we can tell developers they can now remove their untracked orallowSignalWrites from their effects.

ATM, I tend to say it is an "acceptable breaking change".

rainerhahnekamp avatar Mar 06 '24 15:03 rainerhahnekamp

I tried it out, and some tests failed. I have to verify what kind of nature those failures are. Maybe that change has some implications which might be breaking...

rainerhahnekamp avatar Mar 10 '24 16:03 rainerhahnekamp

I'd leave this decision to the Angular team. SignalStore's state signal should behave as any other signal in my opinion - if a signal value update throws an error within the effect by default, the same should happen when SignalStore's state signal is updated within the effect. If the Angular team decides to allow signal writes by default it will be automatically reflected for the SignalStore state updates.

I'm going to convert this issue to a discussion.

markostanimirovic avatar Aug 06 '24 20:08 markostanimirovic