Skip to content

Commit

Permalink
reorder binding functions in stop vs setting prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
brainkim committed Oct 13, 2019
1 parent db00923 commit 02cac2b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/repeater/src/repeater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@ class RepeaterController<T, TReturn = any, TNext = any> {
const push: Push<T> = this.push.bind(this);
const stop: Stop = this.stop.bind(this) as Stop<TReturn>;
const stopP = new Promise<TReturn>((onstop) => (this.onstop = onstop));
stop.then = stopP.then.bind(stopP);
stop.catch = stopP.catch.bind(stopP);
stop.finally = stopP.finally.bind(stopP);
if (typeof Object.setPrototypeOf === "function") {
Object.setPrototypeOf(stop, Promise.prototype);
} else {
(this as any).__proto__ = Promise.prototype;
}

stop.then = stopP.then.bind(stopP);
stop.catch = stopP.catch.bind(stopP);
stop.finally = stopP.finally.bind(stopP);
// Errors which occur in the executor take precedence over those passed to
// this.stop, so calling this.stop with the caught error would be redundant.
try {
Expand Down

0 comments on commit 02cac2b

Please sign in to comment.