Skip to content

Commit 4a42550

Browse files
feat: update to RxJS 7.4.x (#3109)
1 parent a03666b commit 4a42550

File tree

28 files changed

+563
-694
lines changed

28 files changed

+563
-694
lines changed

modules/component-store/jest.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ module.exports = {
22
displayName: 'Component Store',
33
preset: '../../jest.preset.js',
44
coverageDirectory: '../../coverage/libs/component-store',
5-
65
setupFilesAfterEnv: ['<rootDir>/test-setup.ts'],
76
globals: {
87
'ts-jest': {

modules/component-store/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"homepage": "https://github.com/ngrx/platform#readme",
2424
"peerDependencies": {
2525
"@angular/core": "^12.0.0",
26-
"rxjs": "^6.5.3"
26+
"rxjs": "^6.5.3 || ^7.0.0"
2727
},
2828
"schematics": "./schematics/collection.json",
2929
"sideEffects": false,

modules/component-store/spec/component-store.spec.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import {
99
timer,
1010
Observable,
1111
from,
12+
scheduled,
13+
queueScheduler,
14+
asyncScheduler,
1215
} from 'rxjs';
1316
import {
1417
delayWhen,
@@ -754,9 +757,9 @@ describe('Component Store', () => {
754757
(s1, o) => o + ' ' + s1
755758
);
756759

757-
componentStore.updater((state, newValue: string) => ({
758-
value: newValue,
759-
}))(updater$);
760+
scheduled(updater$, asyncScheduler).subscribe((value) => {
761+
componentStore.setState({ value });
762+
});
760763

761764
m.expect(selector$).toBeObservable(expectedSelector$);
762765
})
@@ -823,9 +826,9 @@ describe('Component Store', () => {
823826
(s1, o) => o + ' ' + s1
824827
);
825828

826-
componentStore.updater((state, newValue: string) => ({
827-
value: newValue,
828-
}))(updater$);
829+
scheduled(updater$, asyncScheduler).subscribe((value) => {
830+
componentStore.setState({ value });
831+
});
829832

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

1028-
expect(selectorResults).toEqual([
1029-
{ result: 'empty' },
1030-
{ result: 'new value' },
1031-
]);
1031+
expect(selectorResults).toEqual([{ result: 'new value' }]);
10321032
})
10331033
);
10341034

@@ -1059,9 +1059,9 @@ describe('Component Store', () => {
10591059
{ debounce: true }
10601060
);
10611061

1062-
componentStore.updater((state, newValue: string) => ({
1063-
value: newValue,
1064-
}))(updater$);
1062+
scheduled(updater$, queueScheduler).subscribe((value) => {
1063+
componentStore.setState({ value });
1064+
});
10651065

10661066
m.expect(selector$).toBeObservable(expectedSelector$);
10671067
})
@@ -1125,9 +1125,9 @@ describe('Component Store', () => {
11251125
{ debounce: true }
11261126
);
11271127

1128-
componentStore.updater((state, newValue: string) => ({
1129-
value: newValue,
1130-
}))(updater$);
1128+
scheduled(updater$, queueScheduler).subscribe((value) => {
1129+
componentStore.setState({ value });
1130+
});
11311131

11321132
m.expect(selector$).toBeObservable(expectedSelector$);
11331133
})

modules/component-store/src/component-store.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export class ComponentStore<T extends object> implements OnDestroy {
101101
? () => void
102102
: (observableOrValue: ValueType | Observable<ValueType>) => Subscription
103103
>(updaterFn: (state: T, value: OriginType) => T): ReturnType {
104-
return (((
104+
return ((
105105
observableOrValue?: OriginType | Observable<OriginType>
106106
): Subscription => {
107107
let initializationError: Error | undefined;
@@ -140,7 +140,7 @@ export class ComponentStore<T extends object> implements OnDestroy {
140140
throw /** @type {!Error} */ (initializationError);
141141
}
142142
return subscription;
143-
}) as unknown) as ReturnType;
143+
}) as unknown as ReturnType;
144144
}
145145

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

299-
return (((
299+
return ((
300300
observableOrValue?: ObservableType | Observable<ObservableType>
301301
): Subscription => {
302302
const observable$ = isObservable(observableOrValue)
303303
? observableOrValue
304304
: of(observableOrValue);
305305
return observable$.pipe(takeUntil(this.destroy$)).subscribe((value) => {
306306
// any new 👇 value is pushed into a stream
307-
origin$.next(value);
307+
origin$.next(value as ObservableType);
308308
});
309-
}) as unknown) as ReturnType;
309+
}) as unknown as ReturnType;
310310
}
311311
}
312312

modules/component/jest.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,5 @@ module.exports = {
99
},
1010
},
1111
setupFilesAfterEnv: ['<rootDir>/test-setup.ts'],
12-
1312
transform: { '^.+\\.(ts|js|html)$': 'jest-preset-angular' },
1413
};

modules/component/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"peerDependencies": {
2323
"@angular/common": "^12.0.0",
2424
"@angular/core": "^12.0.0",
25-
"rxjs": "^6.5.3"
25+
"rxjs": "^6.5.3 || ^7.0.0"
2626
},
2727
"schematics": "./schematics/collection.json",
2828
"sideEffects": false,

modules/component/spec/core/cd-aware/cd-aware_creator.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class CdAwareImplementation<U> implements OnDestroy {
4444
resetContextObserver: this.resetContextObserver,
4545
errorHandler,
4646
});
47-
this.subscription = this.cdAware.subscribe();
47+
this.subscription = this.cdAware.subscribe({});
4848
}
4949

5050
ngOnDestroy(): void {

modules/component/src/let/let.directive.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ export class LetDirective<U> implements OnDestroy {
165165
updateViewContextObserver: this.updateViewContextObserver,
166166
errorHandler,
167167
});
168-
this.subscription = this.cdAware.subscribe();
168+
this.subscription = this.cdAware.subscribe({});
169169
}
170170

171171
createEmbeddedView() {

modules/component/src/push/push.pipe.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export class PushPipe<S> implements PipeTransform, OnDestroy {
7979
resetContextObserver: this.resetContextObserver,
8080
errorHandler,
8181
});
82-
this.subscription = this.cdAware.subscribe();
82+
this.subscription = this.cdAware.subscribe({});
8383
}
8484

8585
transform<T>(potentialObservable: null): null;

modules/data/jest.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ module.exports = {
22
displayName: 'Data',
33
preset: '../../jest.preset.js',
44
coverageDirectory: '../../coverage/modules/data',
5-
65
setupFilesAfterEnv: ['<rootDir>/test-setup.ts'],
76
globals: {
87
'ts-jest': {

0 commit comments

Comments
 (0)