Skip to content
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

Upgrade rxbeach to rxjs7 #478

Merged
merged 1 commit into from
Aug 26, 2022
Merged

Upgrade rxbeach to rxjs7 #478

merged 1 commit into from
Aug 26, 2022

Conversation

tlaundal
Copy link
Contributor

@tlaundal tlaundal commented Aug 16, 2022

Upgrade all dependencies to latest version, and in particular update RxJS to 7.5.6.

RxJS has a bunch of breaking changes, the consequences of these in RxBeach are:

  • merge and combineLatest exported from the operators namespace have been renamed with the with suffix
  • Operators reexported from RxJS in RxBeach will have changed signatures as in RxJS
  • The class PersistentReducedStateStream has been deleted, as it relied on extending Observable, and would probably not work in RxJS 8
  • persistentReducedStream now returns instances of the new class ObservableState, which does not extend Observable. Some types will need to be changed.
  • As ObservableState implements InteropObservable it integrates nicely into RxJS, but some custom tooling might need to be updated to accept ObservableInput as arguments, and use the from function from RxJS

This PR is read for review, and possibly merge. It is in use in a team environment in ardoq-front for testing by QA. Once this PR passes review, we need to:

  • Drop the prerelease commit
  • Merge to master (should be fast-forward)
  • Release version 1.0.0

src/index.ts Outdated Show resolved Hide resolved
src/isObservableInput.ts Show resolved Hide resolved
src/observableState.spec.ts Show resolved Hide resolved
src/observableState.ts Outdated Show resolved Hide resolved
Comment on lines +66 to +82
// NOTE: .subscribe(this.subject) does not work
// All tests pass with it, but in practice there are cases
// where the subject isn't updated as expected
// .subscribe({
// complete: () => this.subject.complete(),
// error: (err) => this.subject.error(err),
// next: (state) => this.subject.next(state),
// });
Copy link
Contributor Author

@tlaundal tlaundal Aug 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems this can be removed, unless QA finds anything

src/operators/decorated.ts Outdated Show resolved Hide resolved
reducerFn: Reducer<State, any>
) => {
const wrapper = (state: State, payload: any, namespace?: string) =>
reducerFn(state, payload, namespace);
if (trigger instanceof Observable) {
if (!Array.isArray(trigger) && isObservableInput(trigger)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't really sit well with me, but I think we can fix it after this release

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we discussed, I think from an interface and readability point of view it would be better to have a actionReducer and stateReducer, that would probably also allow to make the code here a bit simpler.

@rafaa2
Copy link
Contributor

rafaa2 commented Aug 16, 2022

@tlaundal Should we change it to ready to review?

@tlaundal
Copy link
Contributor Author

@tlaundal Should we change it to ready to review?

Not yet. I'm making some small changes and plan to rewrite the history. We need to rewrite the history to get a proper changelog when we run the next release.

Updates to RxJS version 7.x. This RxJS update contains many breaking
changes, which leads to breaking changes in RxBeach as well. These
changes also required us to reimplement `PersistentReducedStateStream`,
it is now called `ObservableState`.

Co-authored-by: Tobias Laundal <tobias.laundal@ardoq.com>
BREAKING CHANGE: See breaking changes from RxJS 7.
BREAKING CHANGE: `persistentStateStream` no longer returns an instance
of a subclass of `Observable`, but rather the new class
`ObservableState`.
Copy link

@chriskr chriskr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (not tested)

get destroyed(): boolean {
return this.subject.closed;
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks nice! Quite a bit simpler than the old version.

reducerFn: Reducer<State, any>
) => {
const wrapper = (state: State, payload: any, namespace?: string) =>
reducerFn(state, payload, namespace);
if (trigger instanceof Observable) {
if (!Array.isArray(trigger) && isObservableInput(trigger)) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we discussed, I think from an interface and readability point of view it would be better to have a actionReducer and stateReducer, that would probably also allow to make the code here a bit simpler.

@tlaundal tlaundal merged commit 545cbf0 into master Aug 26, 2022
@tlaundal tlaundal deleted the upgrade-rxbeach-to-rxjs7 branch August 26, 2022 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants