79205010

Date: 2024-11-19 20:54:19
Score: 0.5
Natty:
Report link

If i understand correctly:

You want to reset the store and the state feature to there initial values?

You can add to your StoreFeature a Reset() method that will set the state to it's initial values

export function withMySignalState() {
return signalStoreFeature(
    withState(additionalStates),
    WithMethods(store=>({
    reset():void{
      patchState(store,additonalStates);
    }
    }))

And in the store just

export const MyStore = signalStore(
{ providedIn: 'root' },
withState(initialValues4Store),
withMySignalState(),
WithMethods(()=>({
resetStore():void{
 patchState(store,initialValues4Store);
 reset()://comes from the store feature
}
}))
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: BarakD