feat(component-store): make CS compatible with ViewEngine#2580
Conversation
|
Preview docs changes for b33a54e at https://previews.ngrx.io/pr2580-b33a54ef/ |
| readonly state$: Observable<T> = this.select((s) => s); | ||
|
|
||
| constructor(defaultState?: T) { | ||
| constructor(@Optional() @Inject(initialStateToken) defaultState?: T) { |
There was a problem hiding this comment.
There's a chance you get an initial state here you're not expecting. Maybe we should look at exposing a provider function that let's you provide the token, and the initial state. Separate from this PR though
There was a problem hiding this comment.
TBH, I was hesitant to even export this token. The only reason why it's there, it's because providing of the ComponentStore would fail due to "Can't resolve all parameters for ComponentStore (?)" error. Even with @Optional() Angular still tries to resolve it to something.
This token is help with that search for injectable.
It does open up the possibility to provide both the ComponentStore AND the token in Component's providers but I'd rather not recommend that - because it could lead to another ComponentStore in the downstream Components to be provided with a wrong token.
The solutions for that are complicated and unnecessary, IMHO.
I'm not exporting this token for the public_api.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
Making ComponentStore compatible with ViewEngine. This unfortunately means that we are no longer platform-agnostic.
Also adding integration tests for all kinds of usages that I expect from ComponentStore.
What is the current behavior?
Closes #
What is the new behavior?
Does this PR introduce a breaking change?
Other information