-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(angular): support multiple state slices in data persistence ops #8216
feat(angular): support multiple state slices in data persistence ops #8216
Conversation
A breaking change that enables data persistence operators to be used in streams with more than one slice of data (e.g., with `withLatestFrom` and `concatLatestFrom`). Closes nrwl#6830
☁️ Nx Cloud ReportCI ran the following commands for commit 2126e1a. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this branch ✅ Successfully ran 7 targets
Sent with 💌 from NxCloud. |
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/nrwl/nx-dev/bQnE5z5bx3rWk5KMUgsP7fQUJokx |
Thanks for submitting this PR 🎉 ! Does this still work with a single slice of state, without using I feel like there must be a way to I know we have no tests right now in the Nx repo for this, but it would be super helpful if you could write some tests that covered the following use-cases:
|
In the generic arguments for the various operators, The functions are modified to be variadic, where the arguments have changed from
The type guard for the generic argument
I'll see to it, and see if I can restore the previously commented out cases if possible. |
Thanks for the thorough answer!
This is basically where my concern comes from.
This was a mistype on my part. I did not mean the actual e.g. the return type of Does this mean that using withLatestFrom(this.store.select(myString)),
navigation<AComponent, {
run: (action, [myString]) =>
... will result in
Thanks again for the PR! I just want to make sure we don't introduce breaking changes into existing codebases with this, or introduce type issues for people 🙂 |
Correct, the inferred type is
The generic argument is a tuple, but the actual function argument is variadic. So in your example, one would probably write this instead: withLatestFrom(this.store.select(myString)),
navigation<AComponent, {
run: (action, myString) => // myString is inferred to be a `string`
... But the typing doesn't have to be explicitly provided. The following will infer like so: // with one "slice"
withLatestFrom(this.store.select(myString)),
navigation(AComponent, {
run: (action, myString) => // myString is inferred to be a `string`
// ...
)
// with multiple "slices"
withLatestFrom(this.store.select(myString), this.store.select(myNumber)),
navigation(AComponent, {
run: (action, myString, myNumber) => // myString is inferred to be a `string`, myNumber a `number`
// ...
) |
The only breaking change intended is that explicitly provided generics will need to be updated. It is likely that most consumers of the operators are not explicitly providing generics, but using inference. If one previously used an operator with explicit generic arguments like so: navigate<AComponent, State>(AComponent, { run: (action, state) => {} }) Then they would have to update to: // Only the generic argument for "Slices" changes to be a tuple
navigate<AComponent, [State]>(AComponent, { run: (action, state) => {} }) |
No problem. Thanks for clarifying all that! |
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |
A breaking change that enables data persistence operators to be used in streams with more than one slice of data (e.g., with
withLatestFrom
andconcatLatestFrom
).Closes #6830
Current Behavior
The data persistence operators only work on a single slice of state.
Expected Behavior
The data persistence operators work on multiple slices of state (e.g. selecting multiple slices with
withLatestFrom
andconcatLatestFrom
).Related Issue(s)
Fixes #6830