Skip to content

Commit

Permalink
feat: update to RxJS 7.4.x (#3109)
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonroberts authored Oct 14, 2021
1 parent a03666b commit 4a42550
Show file tree
Hide file tree
Showing 28 changed files with 563 additions and 694 deletions.
1 change: 0 additions & 1 deletion modules/component-store/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module.exports = {
displayName: 'Component Store',
preset: '../../jest.preset.js',
coverageDirectory: '../../coverage/libs/component-store',

setupFilesAfterEnv: ['<rootDir>/test-setup.ts'],
globals: {
'ts-jest': {
Expand Down
2 changes: 1 addition & 1 deletion modules/component-store/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"homepage": "https://github.com/ngrx/platform#readme",
"peerDependencies": {
"@angular/core": "^12.0.0",
"rxjs": "^6.5.3"
"rxjs": "^6.5.3 || ^7.0.0"
},
"schematics": "./schematics/collection.json",
"sideEffects": false,
Expand Down
32 changes: 16 additions & 16 deletions modules/component-store/spec/component-store.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import {
timer,
Observable,
from,
scheduled,
queueScheduler,
asyncScheduler,
} from 'rxjs';
import {
delayWhen,
Expand Down Expand Up @@ -754,9 +757,9 @@ describe('Component Store', () => {
(s1, o) => o + ' ' + s1
);

componentStore.updater((state, newValue: string) => ({
value: newValue,
}))(updater$);
scheduled(updater$, asyncScheduler).subscribe((value) => {
componentStore.setState({ value });
});

m.expect(selector$).toBeObservable(expectedSelector$);
})
Expand Down Expand Up @@ -823,9 +826,9 @@ describe('Component Store', () => {
(s1, o) => o + ' ' + s1
);

componentStore.updater((state, newValue: string) => ({
value: newValue,
}))(updater$);
scheduled(updater$, asyncScheduler).subscribe((value) => {
componentStore.setState({ value });
});

m.expect(selector$).toBeObservable(expectedSelector$);
})
Expand Down Expand Up @@ -1025,10 +1028,7 @@ describe('Component Store', () => {
componentStore.setState(() => ({ value: 'new value', updated: true }));
m.flush();

expect(selectorResults).toEqual([
{ result: 'empty' },
{ result: 'new value' },
]);
expect(selectorResults).toEqual([{ result: 'new value' }]);
})
);

Expand Down Expand Up @@ -1059,9 +1059,9 @@ describe('Component Store', () => {
{ debounce: true }
);

componentStore.updater((state, newValue: string) => ({
value: newValue,
}))(updater$);
scheduled(updater$, queueScheduler).subscribe((value) => {
componentStore.setState({ value });
});

m.expect(selector$).toBeObservable(expectedSelector$);
})
Expand Down Expand Up @@ -1125,9 +1125,9 @@ describe('Component Store', () => {
{ debounce: true }
);

componentStore.updater((state, newValue: string) => ({
value: newValue,
}))(updater$);
scheduled(updater$, queueScheduler).subscribe((value) => {
componentStore.setState({ value });
});

m.expect(selector$).toBeObservable(expectedSelector$);
})
Expand Down
10 changes: 5 additions & 5 deletions modules/component-store/src/component-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export class ComponentStore<T extends object> implements OnDestroy {
? () => void
: (observableOrValue: ValueType | Observable<ValueType>) => Subscription
>(updaterFn: (state: T, value: OriginType) => T): ReturnType {
return (((
return ((
observableOrValue?: OriginType | Observable<OriginType>
): Subscription => {
let initializationError: Error | undefined;
Expand Down Expand Up @@ -140,7 +140,7 @@ export class ComponentStore<T extends object> implements OnDestroy {
throw /** @type {!Error} */ (initializationError);
}
return subscription;
}) as unknown) as ReturnType;
}) as unknown as ReturnType;
}

/**
Expand Down Expand Up @@ -296,17 +296,17 @@ export class ComponentStore<T extends object> implements OnDestroy {
.pipe(takeUntil(this.destroy$))
.subscribe();

return (((
return ((
observableOrValue?: ObservableType | Observable<ObservableType>
): Subscription => {
const observable$ = isObservable(observableOrValue)
? observableOrValue
: of(observableOrValue);
return observable$.pipe(takeUntil(this.destroy$)).subscribe((value) => {
// any new 👇 value is pushed into a stream
origin$.next(value);
origin$.next(value as ObservableType);
});
}) as unknown) as ReturnType;
}) as unknown as ReturnType;
}
}

Expand Down
1 change: 0 additions & 1 deletion modules/component/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ module.exports = {
},
},
setupFilesAfterEnv: ['<rootDir>/test-setup.ts'],

transform: { '^.+\\.(ts|js|html)$': 'jest-preset-angular' },
};
2 changes: 1 addition & 1 deletion modules/component/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"peerDependencies": {
"@angular/common": "^12.0.0",
"@angular/core": "^12.0.0",
"rxjs": "^6.5.3"
"rxjs": "^6.5.3 || ^7.0.0"
},
"schematics": "./schematics/collection.json",
"sideEffects": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class CdAwareImplementation<U> implements OnDestroy {
resetContextObserver: this.resetContextObserver,
errorHandler,
});
this.subscription = this.cdAware.subscribe();
this.subscription = this.cdAware.subscribe({});
}

ngOnDestroy(): void {
Expand Down
2 changes: 1 addition & 1 deletion modules/component/src/let/let.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export class LetDirective<U> implements OnDestroy {
updateViewContextObserver: this.updateViewContextObserver,
errorHandler,
});
this.subscription = this.cdAware.subscribe();
this.subscription = this.cdAware.subscribe({});
}

createEmbeddedView() {
Expand Down
2 changes: 1 addition & 1 deletion modules/component/src/push/push.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export class PushPipe<S> implements PipeTransform, OnDestroy {
resetContextObserver: this.resetContextObserver,
errorHandler,
});
this.subscription = this.cdAware.subscribe();
this.subscription = this.cdAware.subscribe({});
}

transform<T>(potentialObservable: null): null;
Expand Down
1 change: 0 additions & 1 deletion modules/data/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module.exports = {
displayName: 'Data',
preset: '../../jest.preset.js',
coverageDirectory: '../../coverage/modules/data',

setupFilesAfterEnv: ['<rootDir>/test-setup.ts'],
globals: {
'ts-jest': {
Expand Down
2 changes: 1 addition & 1 deletion modules/data/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"@ngrx/store": "12.4.0",
"@ngrx/effects": "12.4.0",
"@ngrx/entity": "12.4.0",
"rxjs": "^6.5.3"
"rxjs": "^6.5.3 || ^7.0.0"
},
"schematics": "./schematics/collection.json",
"ng-update": {
Expand Down
1 change: 0 additions & 1 deletion modules/effects/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module.exports = {
displayName: 'Effects',
preset: '../../jest.preset.js',
coverageDirectory: '../../coverage/modules/effects',

setupFilesAfterEnv: ['<rootDir>/test-setup.ts'],
globals: {
'ts-jest': {
Expand Down
2 changes: 1 addition & 1 deletion modules/effects/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"peerDependencies": {
"@angular/core": "^12.0.0",
"@ngrx/store": "12.4.0",
"rxjs": "^6.5.3"
"rxjs": "^6.5.3 || ^7.0.0"
},
"schematics": "./schematics/collection.json",
"ng-update": {
Expand Down
2 changes: 1 addition & 1 deletion modules/effects/src/concat_latest_from.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export function concatLatestFrom<
: [observables];
return of(value).pipe(
withLatestFrom(...observablesAsArray)
) as Observable<R>;
) as unknown as Observable<R>;
})
);
}
1 change: 0 additions & 1 deletion modules/entity/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module.exports = {
displayName: 'Entity',
preset: '../../jest.preset.js',
coverageDirectory: '../../coverage/modules/entity',

setupFilesAfterEnv: ['<rootDir>/test-setup.ts'],
globals: {
'ts-jest': {
Expand Down
2 changes: 1 addition & 1 deletion modules/entity/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"peerDependencies": {
"@angular/core": "^12.0.0",
"@ngrx/store": "12.4.0",
"rxjs": "^6.5.3"
"rxjs": "^6.5.3 || ^7.0.0"
},
"schematics": "./schematics/collection.json",
"ng-update": {
Expand Down
1 change: 0 additions & 1 deletion modules/router-store/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module.exports = {
displayName: 'Router Store',
preset: '../../jest.preset.js',
coverageDirectory: '../../coverage/modules/router-store',

setupFilesAfterEnv: ['<rootDir>/test-setup.ts'],
globals: {
'ts-jest': {
Expand Down
2 changes: 1 addition & 1 deletion modules/router-store/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"@angular/core": "^12.0.0",
"@angular/router": "^12.0.0",
"@ngrx/store": "12.4.0",
"rxjs": "^6.5.3"
"rxjs": "^6.5.3 || ^7.0.0"
},
"schematics": "./schematics/collection.json",
"ng-update": {
Expand Down
1 change: 0 additions & 1 deletion modules/schematics/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module.exports = {
displayName: 'Schematics',
preset: '../../jest.preset.js',
coverageDirectory: '../../coverage/modules/schematics',

globals: { 'ts-jest': { tsconfig: '<rootDir>/tsconfig.spec.json' } },
testEnvironment: 'node',
};
1 change: 0 additions & 1 deletion modules/store-devtools/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module.exports = {
displayName: 'Store Devtools',
preset: '../../jest.preset.js',
coverageDirectory: '../../coverage/modules/store-devtools',

setupFilesAfterEnv: ['<rootDir>/test-setup.ts'],
globals: {
'ts-jest': {
Expand Down
2 changes: 1 addition & 1 deletion modules/store-devtools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"homepage": "https://github.com/ngrx/platform#readme",
"peerDependencies": {
"@ngrx/store": "12.4.0",
"rxjs": "^6.5.3"
"rxjs": "^6.5.3 || ^7.0.0"
},
"schematics": "./schematics/collection.json",
"ng-update": {
Expand Down
1 change: 0 additions & 1 deletion modules/store/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module.exports = {
displayName: 'Store',
preset: '../../jest.preset.js',
coverageDirectory: '../../coverage/modules/store',

setupFilesAfterEnv: ['<rootDir>/test-setup.ts'],
globals: {
'ts-jest': {
Expand Down
2 changes: 1 addition & 1 deletion modules/store/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"homepage": "https://github.com/ngrx/platform#readme",
"peerDependencies": {
"@angular/core": "^12.0.0",
"rxjs": "^6.5.3"
"rxjs": "^6.5.3 || ^7.0.0"
},
"schematics": "./schematics/collection.json",
"ng-update": {
Expand Down
7 changes: 3 additions & 4 deletions modules/store/src/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ export class State<T> extends BehaviorSubject<any> implements OnDestroy {
const actionsOnQueue$: Observable<Action> = actions$.pipe(
observeOn(queueScheduler)
);
const withLatestReducer$: Observable<
[Action, ActionReducer<any, Action>]
> = actionsOnQueue$.pipe(withLatestFrom(reducer$));
const withLatestReducer$: Observable<[Action, ActionReducer<any, Action>]> =
actionsOnQueue$.pipe(withLatestFrom(reducer$));

const seed: StateActionPair<T> = { state: initialState };
const stateAndAction$: Observable<{
Expand All @@ -49,7 +48,7 @@ export class State<T> extends BehaviorSubject<any> implements OnDestroy {

this.stateSubscription = stateAndAction$.subscribe(({ state, action }) => {
this.next(state);
scannedActions.next(action);
scannedActions.next(action as Action);
});
}

Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
"@nrwl/angular": "12.9.0",
"core-js": "^2.5.4",
"opencollective": "^1.0.3",
"rxjs": "~6.5.5",
"rxjs": "~7.4.0",
"tslib": "^2.2.0",
"zone.js": "0.11.4"
},
Expand Down Expand Up @@ -173,7 +173,7 @@
"husky": "^1.2.0",
"jasmine": "^3.4.0",
"jasmine-core": "3.6.0",
"jasmine-marbles": "0.8.3",
"jasmine-marbles": "0.9.1",
"jasmine-spec-reporter": "5.0.2",
"jest": "27.0.3",
"jest-preset-angular": "9.0.7",
Expand All @@ -200,7 +200,7 @@
"rollup-plugin-commonjs": "10.1.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-sourcemaps": "^0.4.2",
"rxjs-marbles": "^6.0.0",
"rxjs-marbles": "^7.0.1",
"shelljs": "^0.8.3",
"sorcery": "^0.10.0",
"ts-jest": "27.0.3",
Expand All @@ -219,6 +219,7 @@
"logo": "https://opencollective.com/opencollective/logo.txt"
},
"resolutions": {
"jasmine-marbles": "0.9.1",
"listr": "^0.14.2",
"listr-update-renderer": "^0.5.0",
"listr-verbose-renderer": "^0.5.0",
Expand Down
1 change: 0 additions & 1 deletion projects/data-example-app/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module.exports = {
displayName: 'Data Example App',
preset: '../../jest.preset.js',
coverageDirectory: '../../coverage/apps/data-example-app',

setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
globals: {
'ts-jest': {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`View Book Page should compile 1`] = `
<bc-view-book-page
__ngContext__={[Function LRootView]}
actionsSubscription={[Function Subscriber]}
actionsSubscription={[Function SafeSubscriber]}
>
<bc-selected-book-page>
<bc-book-detail>
Expand Down
Loading

0 comments on commit 4a42550

Please sign in to comment.