@@ -367,49 +367,56 @@ const [Observable, Subscriber] = (() => {
367
367
subscribeTo ( this , observer , options ) ;
368
368
}
369
369
370
- // https://pr-preview.s3.amazonaws.com/WICG/ observable/pull/160.html #dom-observable-takeuntil
370
+ // https://wicg.github.io/ observable/#dom-observable-takeuntil
371
371
takeUntil ( value ) {
372
372
if ( ! ( this instanceof Observable ) )
373
373
throw new TypeError ( "illegal invocation" ) ;
374
+
374
375
// 1. Let sourceObservable be this.
375
376
let sourceObservable = this ;
377
+
376
378
// 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
+
378
381
// 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
380
382
return new Observable ( ( subscriber ) => {
381
383
// 3.1. Let notifierObserver be a new internal observer, initialized as follows:
382
384
const notifierObserver = new InternalObserver ( {
385
+ // 3.1.1. For the next callback, run subscriber’s complete() method.
383
386
next ( ) {
384
- // Run subscriber’s complete() method.
385
387
subscriber . complete ( ) ;
386
388
} ,
389
+ // 3.1.2. For the error callback, run subscriber’s complete() method.
387
390
error ( ) {
388
- // Run subscriber’s complete() method.
389
391
subscriber . complete ( ) ;
390
392
} ,
391
393
} ) ;
394
+
392
395
// 3.2. Let options be a new SubscribeOptions whose signal is subscriber’s subscription controller's signal.
393
396
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.
395
399
subscribeTo ( notifier , notifierObserver , options ) ;
400
+
396
401
// 3.4. If subscriber’s active is false, then return.
397
402
if ( ! subscriber . active ) return ;
403
+
398
404
// 3.5. Let sourceObserver be a new internal observer, initialized as follows:
399
405
let sourceObserver = new InternalObserver ( {
406
+ // 3.5.1. For the next callback, run subscriber’s next() method, given the passed in value.
400
407
next ( value ) {
401
- // Run subscriber’s next() method, given the passed in value.
402
408
subscriber . next ( value ) ;
403
409
} ,
410
+ // 3.5.2. For the error callback, run subscriber’s error() method, given the passed in error.
404
411
error ( value ) {
405
- // Run subscriber’s error() method, given the passed in error.
406
412
subscriber . error ( value ) ;
407
413
} ,
414
+ // 3.5.3. For the complete callback, run subscriber’s complete() method.
408
415
complete ( ) {
409
- // Run subscriber’s complete() method.
410
416
subscriber . complete ( ) ;
411
417
} ,
412
418
} ) ;
419
+
413
420
// 3.6. Subscribe to sourceObservable given sourceObserver and options.
414
421
subscribeTo ( sourceObservable , sourceObserver , options ) ;
415
422
} ) ;
0 commit comments