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
Sometimes, our Signal Store Features require features from the store they should be plugged in. Since features should be re-usable, direct coupling is impossible.
Following use case. A feature requires access to a loading function which is defined in withMethods of the store.
interfacePerson{firstname: string;lastname: string;}signalStore(withMethods(()=>{consthttpClient=inject(HttpClient);return{load(){returnhttpClient.get<Person[]>('someUrl');},};}),withEntityVersioner(()=>store.load())// does not compile);
The proposed feature is about a function withFeatureFactory which connects an autonomous feature to a specific store.
Which @ngrx/* package(s) are relevant/related to the feature request?
signals
Information
This is a proposal for connector function which connects a signalStore to a feature and provides the feature access to store-specific elements.
A StackBlitz example is available here: https://stackblitz.com/edit/ngrx-signal-store-starter-wkuxdh
Sometimes, our Signal Store Features require features from the store they should be plugged in. Since features should be re-usable, direct coupling is impossible.
Following use case. A feature requires access to a loading function which is defined in
withMethods
of the store.We have the following feature
And a store which wants to use it:
The proposed feature is about a function
withFeatureFactory
which connects an autonomous feature to a specific store.The type of
withFeatureFactory
would look like this:This feature would be helpful in the discussion #4338.
Although, it is different use case, it is very similar to the suggestion of @gabrielguerrero in #4314 (comment)
Describe any alternatives/workarounds you're currently using
The alternative is that the
load
function in the example would come from a service which thesignalStoreFeature
has to inject.I would be willing to submit a PR to fix this issue
The text was updated successfully, but these errors were encountered: