Skip to content

Commit

Permalink
fix(@angular-devkit/core): avoid RxJS performance penalty in sync fs …
Browse files Browse the repository at this point in the history
…calls
  • Loading branch information
JoostK committed Aug 16, 2020
1 parent ba81dec commit 015c6a6
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/angular_devkit/core/src/virtual-fs/host/sync.ts
Expand Up @@ -37,11 +37,13 @@ export class SyncDelegateHost<T extends object = {}> {
let completed = false;
let result: ResultT | undefined = undefined;
let errorResult: Error | undefined = undefined;
observable.subscribe({
next(x: ResultT) { result = x; },
error(err: Error) { errorResult = err; },
complete() { completed = true; },
});
// Perf note: this is not using an observer object to avoid a performance penalty in RxJS.
// See https://github.com/ReactiveX/rxjs/pull/5646 for details.
observable.subscribe(
(x: ResultT) => result = x,
(err: Error) => errorResult = err,
() => completed = true,
);

if (errorResult !== undefined) {
throw errorResult;
Expand Down

0 comments on commit 015c6a6

Please sign in to comment.