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
I'm working with the new @ngrx/signals store and have a question about best practices.
In my store, I need to get a specific entity by its key (e.g., symbol by code). Since withComputed only allows parameterless computed values, I implemented a method via withMethods that returns a computed Signal<T> based on the argument:
This works well for my use case, and the component stays reactive.
However, I’ve noticed that most examples use withMethods for state mutations (e.g., update, patchState) and I haven’t seen examples where values are returned to components directly via methods.
My question:
Is it considered good practice to expose reactive getters with arguments via withMethods, like in the example above?
Or is there a more idiomatic or recommended approach for this pattern?
Thanks in advance for the clarification and for the amazing work on signal store — it's been a joy to use!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi! 👋
I'm working with the new
@ngrx/signals
store and have a question about best practices.In my store, I need to get a specific entity by its key (e.g., symbol by code). Since
withComputed
only allows parameterless computed values, I implemented a method viawithMethods
that returns a computedSignal<T>
based on the argument:This works well for my use case, and the component stays reactive.
However, I’ve noticed that most examples use
withMethods
for state mutations (e.g.,update
,patchState
) and I haven’t seen examples where values are returned to components directly via methods.My question:
Thanks in advance for the clarification and for the amazing work on signal store — it's been a joy to use!
Beta Was this translation helpful? Give feedback.
All reactions