Skip to content

Commit f0019a8

Browse files
committed
fix .takeUntil +notes
1 parent a1b1da8 commit f0019a8

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

observable.js

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -367,49 +367,56 @@ const [Observable, Subscriber] = (() => {
367367
subscribeTo(this, observer, options);
368368
}
369369

370-
// https://pr-preview.s3.amazonaws.com/WICG/observable/pull/160.html#dom-observable-takeuntil
370+
// https://wicg.github.io/observable/#dom-observable-takeuntil
371371
takeUntil(value) {
372372
if (!(this instanceof Observable))
373373
throw new TypeError("illegal invocation");
374+
374375
// 1. Let sourceObservable be this.
375376
let sourceObservable = this;
377+
376378
// 2. Let notifier be the result of converting value to an Observable.
377-
let notifier = Observable.from(this);
379+
let notifier = Observable.from(value);
380+
378381
// 3. Let observable be a new Observable whose subscribe callback is an algorithm that takes a Subscriber subscriber and does the following:
379-
// 4. return observable
380382
return new Observable((subscriber) => {
381383
// 3.1. Let notifierObserver be a new internal observer, initialized as follows:
382384
const notifierObserver = new InternalObserver({
385+
// 3.1.1. For the next callback, run subscriber’s complete() method.
383386
next() {
384-
// Run subscriber’s complete() method.
385387
subscriber.complete();
386388
},
389+
// 3.1.2. For the error callback, run subscriber’s complete() method.
387390
error() {
388-
// Run subscriber’s complete() method.
389391
subscriber.complete();
390392
},
391393
});
394+
392395
// 3.2. Let options be a new SubscribeOptions whose signal is subscriber’s subscription controller's signal.
393396
let options = { signal: subscriber.signal };
394-
// 3.3 Subscribe to notifier given notifierObserver and options.
397+
398+
// 3.3. Subscribe to notifier given notifierObserver and options.
395399
subscribeTo(notifier, notifierObserver, options);
400+
396401
// 3.4. If subscriber’s active is false, then return.
397402
if (!subscriber.active) return;
403+
398404
// 3.5. Let sourceObserver be a new internal observer, initialized as follows:
399405
let sourceObserver = new InternalObserver({
406+
// 3.5.1. For the next callback, run subscriber’s next() method, given the passed in value.
400407
next(value) {
401-
// Run subscriber’s next() method, given the passed in value.
402408
subscriber.next(value);
403409
},
410+
// 3.5.2. For the error callback, run subscriber’s error() method, given the passed in error.
404411
error(value) {
405-
// Run subscriber’s error() method, given the passed in error.
406412
subscriber.error(value);
407413
},
414+
// 3.5.3. For the complete callback, run subscriber’s complete() method.
408415
complete() {
409-
// Run subscriber’s complete() method.
410416
subscriber.complete();
411417
},
412418
});
419+
413420
// 3.6. Subscribe to sourceObservable given sourceObserver and options.
414421
subscribeTo(sourceObservable, sourceObserver, options);
415422
});

0 commit comments

Comments
 (0)