This repository has been archived by the owner on Feb 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 407
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(rxjs): asap should runGuarded to let error inZone (#884)
* fix(rxjs): asap should runGuarded to let error inZone * add document for how to load rxjs patch
- Loading branch information
1 parent
a733688
commit ce3f12f
Showing
4 changed files
with
111 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* @license | ||
* Copyright Google Inc. All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
import * as Rx from 'rxjs/Rx'; | ||
import {asyncTest} from '../test-util'; | ||
|
||
describe('Scheduler.asap', () => { | ||
let log: string[]; | ||
let errorCallback: Function; | ||
const constructorZone: Zone = Zone.root.fork({ | ||
name: 'Constructor Zone', | ||
onHandleError: (delegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, error: Error) => { | ||
log.push('error' + error.message); | ||
const result = delegate.handleError(targetZone, error); | ||
errorCallback && errorCallback(); | ||
return false; | ||
} | ||
}); | ||
|
||
beforeEach(() => { | ||
log = []; | ||
}); | ||
|
||
it('scheduler asap error should run in correct zone', asyncTest((done: any) => { | ||
let observable: any; | ||
constructorZone.run(() => { | ||
observable = Rx.Observable.of(1, 2, 3).observeOn(Rx.Scheduler.asap); | ||
}); | ||
|
||
errorCallback = () => { | ||
expect(log).toEqual(['erroroops']); | ||
setTimeout(done, 0); | ||
}; | ||
|
||
Zone.root.run(() => { | ||
observable | ||
.map((value: number) => { | ||
if (value === 3) { | ||
throw new Error('oops'); | ||
} | ||
return value; | ||
}) | ||
.subscribe((value: number) => {}); | ||
}); | ||
}, Zone.root)); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters