niklas-wortmann / xstate-angular

POC Xstate Angular Implementation
10 stars 2 forks source link

DeepSignal for Actor context #13

Open matheo opened 6 days ago

matheo commented 6 days ago

Looking the source code of ngrx/signals they convert the object to a Deep Signal: https://github.com/ngrx/platform/blob/main/modules/signals/src/deep-signal.ts and it seems very useful to extract the context variables (only?) of an Actor.

I've spawned an Actor and assigned it into the Context and it would be nice if we can extract a Deep Signal from the child Actor context too.

niklas-wortmann commented 5 days ago

I was thinking about this and don't see the benefit for now. Can you elaborate on the use case or show some examples? This also reads like 2 separate requests deep signal vs exposed context?

Deep signal would mean an API like: this.machine.snapshot().context.someProp().someNestedProp() vs. exposed context this.machine.someProp()

matheo commented 5 days ago

I've got an Actor with a large set of flags/stuff in its context to be rendered in the component and the Deep Signal is a solution to access the singular data fields easily for these cases.

niklas-wortmann commented 5 days ago

Yeah I guess that makes sense. Sounds like a good idea. I will look into it at some point

matheo commented 4 days ago

In the meantime I'm using my own useSelector with a copy of toDeepSignal from ngrx https://github.com/ngrx/platform/pull/4533