Skip to content

Commit 77ee70e

Browse files
JoostKalan-agius4
authored andcommitted
fix(@angular-devkit/core): avoid RxJS performance penalty in sync fs calls
(cherry picked from commit 876df75)
1 parent 909b10a commit 77ee70e

File tree

1 file changed

+7
-5
lines changed
  • packages/angular_devkit/core/src/virtual-fs/host

1 file changed

+7
-5
lines changed

packages/angular_devkit/core/src/virtual-fs/host/sync.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,13 @@ export class SyncDelegateHost<T extends object = {}> {
3737
let completed = false;
3838
let result: ResultT | undefined = undefined;
3939
let errorResult: Error | undefined = undefined;
40-
observable.subscribe({
41-
next(x: ResultT) { result = x; },
42-
error(err: Error) { errorResult = err; },
43-
complete() { completed = true; },
44-
});
40+
// Perf note: this is not using an observer object to avoid a performance penalty in RxJS.
41+
// See https://github.com/ReactiveX/rxjs/pull/5646 for details.
42+
observable.subscribe(
43+
(x: ResultT) => result = x,
44+
(err: Error) => errorResult = err,
45+
() => completed = true,
46+
);
4547

4648
if (errorResult !== undefined) {
4749
throw errorResult;

0 commit comments

Comments
 (0)