spierala / mini-rx-store

MiniRx - The reactive state management platform
https://mini-rx.io
Other
170 stars 9 forks source link

With SignalStore what 's the best way to get the raw state #214

Closed marcpearson closed 7 months ago

marcpearson commented 7 months ago

When using some class store's functions (class implement FeatureStore), i need to get the RAW state from the signal FeatureStore. My implemented FeatureStore is injected in Angular constructor. I tried to used the state() (this.store.state().XYZ) but the function is deprecated and still not replaced Using this.store.select() return a signal. To get the RAW state i need to write this.store.select()() and it's very ugly.

What is the best practice to obtain the raw state from the store presently ?

spierala commented 7 months ago

Hi @marcpearson

The deprecated state getter function returns a Signal... but we decided that it should return the raw state in the future (as it is the case for the original MiniRx Store).

Now I created this pull request to make the state getter to return the raw state: https://github.com/spierala/mini-rx-store/pull/215

Because this is a breaking change we will release a version 2 of the MiniRx Signal Store. I expect to release v2 this week.

Till then this.select()() is the best way to retrieve the raw state. Admittedly that is quite ugly. But the fix is underway.

spierala commented 7 months ago

Hey @marcpearson

we just released v2 of @mini-rx/signal-store: https://www.npmjs.com/package/@mini-rx/signal-store the state getter function returns now the raw state.