Skip to content

The signalStore function could return two functions, one for provide and one for inject. #4188

Discussion options

You must be logged in to vote

For an example of what I mean, you can check the createInjectionToken function in the ngextension library.
https://ngxtension.netlify.app/utilities/injectors/create-injection-token/

The idea with [provide, inject] tuple is from initial SignalStore proposal.

The injection token's limitation is that it cannot be provided via the providers array without useFactory. That's the reason why the provide.. function is necessary for tokens. On the other hand, this is not needed for services (classes).

By the way, I opened an issue for this some time ago: angular/angular#49807

It would be convenient if the signalStore function, instead of returning the class to use for providing and injecting, re…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@MRinaldi9
Comment options

@markostanimirovic
Comment options

Answer selected by MRinaldi9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
2 participants
Converted from issue

This discussion was converted from issue #4184 on December 24, 2023 21:10.