Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(observeOn-spec): use a scheduler instead of setInterval #2252

Merged
merged 1 commit into from
Jan 5, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions spec/operators/observeOn-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,18 @@ describe('Observable.prototype.observeOn', () => {
//HACK: Deep introspection to make sure we're cleaning up notifications in scheduling.
// as the architecture changes, this test may become brittle.
const results = [];
// This is to build a scheduled observable with a slightly more stable
// subscription structure, since we're going to hack in to analyze it in this test.
const subscription: any = new Observable(observer => {
let i = 1;
const id = setInterval(() => {
return Rx.Scheduler.asap.schedule(function () {
if (i > 3) {
observer.complete();
} else {
observer.next(i++);
this.schedule();
}
}, 0);

return () => clearInterval(id);
});
})
.observeOn(Rx.Scheduler.asap)
.subscribe(
Expand Down