Comparing version 1.0.23 to 1.0.24
@@ -19,5 +19,5 @@ // This file is created to avoid circular reference between RN and operators. | ||
export * from './operators/take'; | ||
export * from './operators/terminateBy'; | ||
export * from './operators/takeUntil'; | ||
export * from './operators/throttle'; | ||
export * from './operators/withInitialValue'; | ||
export * from './operators/withLatest'; |
@@ -29,3 +29,3 @@ /* removed in prod */ import { RN } from '../mod'; | ||
complete() { | ||
protected complete() { | ||
super.complete(); | ||
@@ -32,0 +32,0 @@ clearTimeout( this.timerId ); |
@@ -26,3 +26,3 @@ /* removed in prod */ import { RN } from '../mod'; | ||
complete() { | ||
protected complete() { | ||
super.complete(); | ||
@@ -29,0 +29,0 @@ clearTimeout( this.timerId ); |
@@ -24,3 +24,3 @@ /* removed in prod */ import { RN } from '../mod'; | ||
complete() { | ||
protected complete() { | ||
super.complete(); | ||
@@ -27,0 +27,0 @@ clearTimeout( this.timerId ); |
@@ -36,3 +36,3 @@ /* removed in prod */ import { RN } from '../mod'; | ||
complete() { | ||
protected complete() { | ||
super.complete(); | ||
@@ -39,0 +39,0 @@ this.subscriptions.forEach( s => s.unsubscribe() ); |
@@ -30,3 +30,3 @@ /* removed in prod */ import { RN } from '../mod'; | ||
complete() { | ||
protected complete() { | ||
super.complete(); | ||
@@ -33,0 +33,0 @@ this.appeared.clear(); |
@@ -36,3 +36,3 @@ /* removed in prod */ import { RN } from '../mod'; | ||
complete() { | ||
protected complete() { | ||
super.complete(); | ||
@@ -39,0 +39,0 @@ this.subscription.unsubscribe(); |
@@ -30,3 +30,3 @@ import { RNId } from './types/RNId'; | ||
/* removed in prod */ takeWhile, | ||
/* removed in prod */ terminateBy, | ||
/* removed in prod */ takeUntil, | ||
/* removed in prod */ throttle, | ||
@@ -79,3 +79,3 @@ /* removed in prod */ withInitialValue, | ||
this.parentsInternal = parents; | ||
this.parents.forEach( src => src.addChild( this ) ); | ||
this.parents.forEach( src => src.addChild(this) ); | ||
@@ -97,5 +97,5 @@ this.priority = 1 + this.parents.reduce( | ||
private static addTasks( rns: RN<any>[] ) { | ||
private static addTasks(rns: RN<any>[]) { | ||
if ( !rns || rns.length === 0 ) return; | ||
rns.forEach( rn => this.addAsHeapUniq( rn ) ); | ||
rns.forEach( rn => this.addAsHeapUniq(rn) ); | ||
if ( !this.engine.doTaskIsRunning ) this.doTask(); | ||
@@ -115,15 +115,15 @@ } | ||
private static exists( newValue: RN<any> ): boolean { | ||
return ( this.engine.priorityQueue.findIndex( e => e.id === newValue.id ) !== -1 ); | ||
private static exists(newValue: RN<any>): boolean { | ||
return (this.engine.priorityQueue.findIndex(e => e.id === newValue.id) !== -1); | ||
} | ||
private static addAsHeapUniq( newValue: RN<any> ) { | ||
if ( !this.exists( newValue ) ) { | ||
this.addAsHeap( newValue ); | ||
private static addAsHeapUniq(newValue: RN<any>) { | ||
if ( !this.exists(newValue) ) { | ||
this.addAsHeap(newValue); | ||
} | ||
} | ||
private static addAsHeap( newValue: RN<any> ) { | ||
private static addAsHeap(newValue: RN<any>) { | ||
const heap = this.engine.priorityQueue; | ||
heap.push( newValue ); | ||
heap.push(newValue); | ||
if ( heap.length <= 1 ) return; | ||
@@ -194,10 +194,10 @@ | ||
private addChild( c: RN<any> ) { | ||
private addChild(c: RN<any>) { | ||
if ( !c ) return; | ||
this.children.push( c ); | ||
this.children.push(c); | ||
} | ||
private addSubscriber( s: Subscriber<T> ) { | ||
private addSubscriber(s: Subscriber<T>) { | ||
// return the index of added subscriber | ||
return this.subscribers.push( s ) - 1; | ||
return this.subscribers.push(s) - 1; | ||
} | ||
@@ -209,3 +209,3 @@ | ||
protected fireWith( v: T ) { | ||
protected fireWith(v: T) { | ||
if ( this.isCompleted ) return; | ||
@@ -217,6 +217,6 @@ | ||
// run subscribers for the current value | ||
this.subscribers.forEach( s => { s.next( this.value ); }); | ||
this.subscribers.forEach(s => { s.next( this.value ); }); | ||
// propagate to children | ||
RN.addTasks( this.children ); | ||
RN.addTasks(this.children); | ||
} | ||
@@ -242,7 +242,7 @@ | ||
&& | ||
this.parents.every( r => r.isCompleted ) | ||
this.parents.every(r => r.isCompleted) | ||
) || ( | ||
this.subscribers.length === 0 | ||
&& | ||
this.children.every( r => r.isCompleted ) | ||
this.children.every(r => r.isCompleted) | ||
) | ||
@@ -260,6 +260,6 @@ ) { | ||
this.promiseResolver( this.value ); | ||
this.promiseResolver(this.value); | ||
// run subscribers for the current value | ||
this.subscribers.forEach( s => { s.complete( this.value ); }); | ||
this.subscribers.forEach(s => { s.complete(this.value); }); | ||
@@ -270,6 +270,6 @@ // remove all subscribers | ||
// propagate to children | ||
this.children.forEach( rn => { rn.askIfComplete(); }); | ||
this.children.forEach(rn => { rn.askIfComplete(); }); | ||
// propagate to parents | ||
this.parents.forEach( rn => { rn.askIfComplete(); }); | ||
// this.parents.forEach( rn => { rn.askIfComplete(); }); | ||
} | ||
@@ -287,3 +287,3 @@ | ||
// run subscribers for the current value | ||
this.subscribers.forEach( s => { s.error( this.value ); }); | ||
this.subscribers.forEach(s => { s.error( this.value ); }); | ||
@@ -294,6 +294,6 @@ // remove all subscribers | ||
// propagate to children | ||
this.children.forEach( rn => { rn.completeWithError(); }); | ||
this.children.forEach(rn => { rn.completeWithError(); }); | ||
// propagate to parents | ||
this.parents.forEach( rn => { rn.askIfComplete(); }); | ||
// this.parents.forEach( rn => { rn.askIfComplete(); }); | ||
} | ||
@@ -311,3 +311,3 @@ | ||
): Subscription { | ||
return this.subscribe( onFire, onError, onComplete, runWithFirstValue ); | ||
return this.subscribe(onFire, onError, onComplete, runWithFirstValue); | ||
} | ||
@@ -400,3 +400,3 @@ | ||
): Subscription { | ||
return this.terminateBy( terminator ) | ||
return this.takeUntil( terminator ) | ||
.listen( runWithFirstValue, onFire, onError, onComplete ); | ||
@@ -500,12 +500,12 @@ } | ||
auditTime( time: number ): RN<T> { | ||
return auditTime<T>( time )( this ); | ||
auditTime(time: number): RN<T> { | ||
return auditTime<T>(time)(this); | ||
} | ||
debounce( time: number ): RN<T> { | ||
return debounce<T>( time )( this ); | ||
debounce(time: number): RN<T> { | ||
return debounce<T>(time)(this); | ||
} | ||
delay( time: number ): RN<T> { | ||
return delay<T>( time )( this ); | ||
delay(time: number): RN<T> { | ||
return delay<T>(time)(this); | ||
} | ||
@@ -517,3 +517,3 @@ | ||
): RN<T> { | ||
return filter<T>( initialValue, predicate )( this ); | ||
return filter<T>(initialValue, predicate)(this); | ||
} | ||
@@ -524,3 +524,3 @@ | ||
): RN<U> { | ||
return flatMap<T, U>( fn )( this ); | ||
return flatMap<T, U>(fn)(this); | ||
} | ||
@@ -531,27 +531,27 @@ | ||
): RN<U> { | ||
return map<T, U>( fn )( this ); | ||
return map<T, U>(fn)(this); | ||
} | ||
mapTo<U>( value: U ): RN<U> { | ||
return mapTo<T, U>( value )( this ); | ||
mapTo<U>(value: U): RN<U> { | ||
return mapTo<T, U>(value)(this); | ||
} | ||
valueIs( value: T ): RN<boolean> { | ||
return valueIs<T>( value )( this ); | ||
valueIs(value: T): RN<boolean> { | ||
return valueIs<T>(value)(this); | ||
} | ||
valueIsNot( value: T ): RN<boolean> { | ||
return valueIsNot<T>( value )( this ); | ||
valueIsNot(value: T): RN<boolean> { | ||
return valueIsNot<T>(value)(this); | ||
} | ||
pluck<K extends keyof T>( member: K ): RN<T[K]> { | ||
return pluck<T, K>( member )( this ); | ||
pluck<K extends keyof T>(member: K): RN<T[K]> { | ||
return pluck<T, K>(member)(this); | ||
} | ||
withTimestamp(): RN<[T, number]> { | ||
return withTimestamp<T>()( this ); | ||
return withTimestamp<T>()(this); | ||
} | ||
pairwise( initialPrevValue?: T ): RN<[T, T]> { | ||
return pairwise<T>( initialPrevValue )( this ); | ||
pairwise(initialPrevValue?: T): RN<[T, T]> { | ||
return pairwise<T>(initialPrevValue)(this); | ||
} | ||
@@ -563,7 +563,7 @@ | ||
): RN<U> { | ||
return scan<T, U>( initialValue, fn )( this ); | ||
return scan<T, U>(initialValue, fn)(this); | ||
} | ||
skip( initialValue: T, skipNum: number ): RN<T> { | ||
return skip<T>( initialValue, skipNum )( this ); | ||
skip(initialValue: T, skipNum: number): RN<T> { | ||
return skip<T>(initialValue, skipNum)(this); | ||
} | ||
@@ -575,15 +575,15 @@ | ||
): RN<T> { | ||
return skipWhile<T>( initialValue, predicate )( this ); | ||
return skipWhile<T>(initialValue, predicate)(this); | ||
} | ||
skipAlreadyAppeared<K extends keyof T>( key?: K ): RN<T> { | ||
return skipAlreadyAppeared<T, K>( key )( this ); | ||
return skipAlreadyAppeared<T, K>(key)(this); | ||
} | ||
skipUnchanged( eq?: (a: T, b: T) => boolean ): RN<T> { | ||
return skipUnchanged<T>( eq )( this ); | ||
skipUnchanged(eq?: (a: T, b: T) => boolean): RN<T> { | ||
return skipUnchanged<T>(eq)(this); | ||
} | ||
startWith( initialValue: T ): RN<T> { | ||
return startWith( initialValue )( this ); | ||
startWith(initialValue: T): RN<T> { | ||
return startWith(initialValue)(this); | ||
} | ||
@@ -594,7 +594,7 @@ | ||
): RN<U> { | ||
return switchMap<T, U>( fn )( this ); | ||
return switchMap<T, U>(fn)(this); | ||
} | ||
take( takeNum: number ): RN<T> { | ||
return take<T>( takeNum )( this ); | ||
take(takeNum: number): RN<T> { | ||
return take<T>(takeNum)(this); | ||
} | ||
@@ -605,21 +605,24 @@ | ||
): RN<T> { | ||
return takeWhile<T>( predicate )( this ); | ||
return takeWhile<T>(predicate)(this); | ||
} | ||
takeUntil(terminator: RN<void>): RN<T> { | ||
return takeUntil<T>(terminator)(this); | ||
} | ||
terminateBy(terminator: RN<void>): RN<T> { | ||
return terminateBy<T>( terminator )( this ); | ||
return takeUntil<T>(terminator)(this); | ||
} | ||
throttle( time: number ): RN<T> { | ||
return throttle<T>( time )( this ); | ||
throttle(time: number): RN<T> { | ||
return throttle<T>(time)(this); | ||
} | ||
withInitialValue( initialValue: T ): RN<T> { | ||
return withInitialValue( initialValue )( this ); | ||
withInitialValue(initialValue: T): RN<T> { | ||
return withInitialValue(initialValue)(this); | ||
} | ||
withLatest<U>( src: RN<U> ): RN<[T, U]> { | ||
return withLatest<T, U>( src )( this ); | ||
withLatest<U>(src: RN<U>): RN<[T, U]> { | ||
return withLatest<T, U>(src)(this); | ||
} | ||
} |
@@ -37,3 +37,3 @@ import { RN } from '../RN'; | ||
complete() { | ||
protected complete() { | ||
super.complete(); | ||
@@ -40,0 +40,0 @@ clearInterval( this.timerId ); |
@@ -23,2 +23,3 @@ export { | ||
takeWhile, | ||
takeUntil, | ||
terminateBy, | ||
@@ -25,0 +26,0 @@ throttle, |
@@ -26,2 +26,3 @@ import { | ||
setTimeout(() => { intv.stop(); }, 3000); | ||
@@ -28,0 +29,0 @@ // Mutation is not |
@@ -16,5 +16,5 @@ export * from './RN'; | ||
export * from './operators/take'; | ||
export * from './operators/terminateBy'; | ||
export * from './operators/takeUntil'; | ||
export * from './operators/throttle'; | ||
export * from './operators/withInitialValue'; | ||
export * from './operators/withLatest'; |
@@ -22,5 +22,5 @@ "use strict"; | ||
__export(require("./operators/take")); | ||
__export(require("./operators/terminateBy")); | ||
__export(require("./operators/takeUntil")); | ||
__export(require("./operators/throttle")); | ||
__export(require("./operators/withInitialValue")); | ||
__export(require("./operators/withLatest")); |
@@ -74,2 +74,3 @@ import { Subscriber } from './types/Subscriber'; | ||
takeWhile(predicate: (srcValue: T, srcIndex: number, index: number) => boolean): RN<T>; | ||
takeUntil(terminator: RN<void>): RN<T>; | ||
terminateBy(terminator: RN<void>): RN<T>; | ||
@@ -76,0 +77,0 @@ throttle(time: number): RN<T>; |
@@ -157,3 +157,3 @@ "use strict"; | ||
// propagate to parents | ||
this.parents.forEach(rn => { rn.askIfComplete(); }); | ||
// this.parents.forEach( rn => { rn.askIfComplete(); }); | ||
} | ||
@@ -173,3 +173,3 @@ completeWithError() { | ||
// propagate to parents | ||
this.parents.forEach(rn => { rn.askIfComplete(); }); | ||
// this.parents.forEach( rn => { rn.askIfComplete(); }); | ||
} | ||
@@ -231,3 +231,3 @@ listen(runWithFirstValue = true, onFire, onError, onComplete) { | ||
listenUntil(terminator, runWithFirstValue = true, onFire, onError, onComplete) { | ||
return this.terminateBy(terminator) | ||
return this.takeUntil(terminator) | ||
.listen(runWithFirstValue, onFire, onError, onComplete); | ||
@@ -322,4 +322,7 @@ } | ||
} | ||
takeUntil(terminator) { | ||
return mod_1.takeUntil(terminator)(this); | ||
} | ||
terminateBy(terminator) { | ||
return mod_1.terminateBy(terminator)(this); | ||
return mod_1.takeUntil(terminator)(this); | ||
} | ||
@@ -326,0 +329,0 @@ throttle(time) { |
@@ -11,4 +11,4 @@ import { RN } from '../RN'; | ||
stop(): void; | ||
complete(): void; | ||
protected complete(): void; | ||
} | ||
export {}; |
@@ -1,1 +0,1 @@ | ||
export { auditTime, debounce, delay, filter, flatMap, map, mapTo, valueIs, valueIsNot, withTimestamp, pluck, pairwise, scan, skipAlreadyAppeared, skipUnchanged, skip, skipWhile, startWith, switchMap, take, takeWhile, terminateBy, throttle, withLatest, withInitialValue, } from './internal/mod'; | ||
export { auditTime, debounce, delay, filter, flatMap, map, mapTo, valueIs, valueIsNot, withTimestamp, pluck, pairwise, scan, skipAlreadyAppeared, skipUnchanged, skip, skipWhile, startWith, switchMap, take, takeWhile, takeUntil, terminateBy, throttle, withLatest, withInitialValue, } from './internal/mod'; |
@@ -25,2 +25,3 @@ "use strict"; | ||
exports.takeWhile = mod_1.takeWhile; | ||
exports.takeUntil = mod_1.takeUntil; | ||
exports.terminateBy = mod_1.terminateBy; | ||
@@ -27,0 +28,0 @@ exports.throttle = mod_1.throttle; |
@@ -15,2 +15,3 @@ "use strict"; | ||
intv.listenUntil(terminator, true, v => console.log(v), undefined, () => console.log('end')); | ||
setTimeout(() => { intv.stop(); }, 3000); | ||
// Mutation is not | ||
@@ -17,0 +18,0 @@ // foo.bar = 456; |
@@ -74,2 +74,3 @@ import { Subscriber } from './types/Subscriber'; | ||
takeWhile(predicate: (srcValue: T, srcIndex: number, index: number) => boolean): RN<T>; | ||
takeUntil(terminator: RN<void>): RN<T>; | ||
terminateBy(terminator: RN<void>): RN<T>; | ||
@@ -76,0 +77,0 @@ throttle(time: number): RN<T>; |
@@ -156,3 +156,3 @@ "use strict"; | ||
// propagate to parents | ||
this.parents.forEach(rn => { rn.askIfComplete(); }); | ||
// this.parents.forEach( rn => { rn.askIfComplete(); }); | ||
} | ||
@@ -172,3 +172,3 @@ completeWithError() { | ||
// propagate to parents | ||
this.parents.forEach(rn => { rn.askIfComplete(); }); | ||
// this.parents.forEach( rn => { rn.askIfComplete(); }); | ||
} | ||
@@ -230,3 +230,3 @@ listen(runWithFirstValue = true, onFire, onError, onComplete) { | ||
listenUntil(terminator, runWithFirstValue = true, onFire, onError, onComplete) { | ||
return this.terminateBy(terminator) | ||
return this.takeUntil(terminator) | ||
.listen(runWithFirstValue, onFire, onError, onComplete); | ||
@@ -321,4 +321,7 @@ } | ||
} | ||
takeUntil(terminator) { | ||
return exports.takeUntil(terminator)(this); | ||
} | ||
terminateBy(terminator) { | ||
return exports.terminateBy(terminator)(this); | ||
return exports.takeUntil(terminator)(this); | ||
} | ||
@@ -573,8 +576,9 @@ throttle(time) { | ||
} | ||
exports.terminateBy = (terminator) => ((src) => new TerminateByRN(src, terminator)); | ||
exports.takeUntil = (terminator) => ((src) => new TerminateByRN(src, terminator)); | ||
class TerminateByRN extends RN { | ||
exports.terminateBy = (terminator) => ((src) => new TakeUntilRN(src, terminator)); | ||
exports.takeUntil = (terminator) => ((src) => new TakeUntilRN(src, terminator)); | ||
class TakeUntilRN extends RN { | ||
constructor(src, terminator) { | ||
super(src.value, [src]); | ||
this.subscription = terminator.listen(false, () => { }, () => { }, () => this.terminate()); | ||
const terminate = () => this.complete(); | ||
this.subscription = terminator.listen(false, terminate, () => { }, terminate); | ||
} | ||
@@ -581,0 +585,0 @@ fire() { |
@@ -11,4 +11,4 @@ import { RN } from '../RN'; | ||
stop(): void; | ||
complete(): void; | ||
protected complete(): void; | ||
} | ||
export {}; |
@@ -1,1 +0,1 @@ | ||
export { auditTime, debounce, delay, filter, flatMap, map, mapTo, valueIs, valueIsNot, withTimestamp, pluck, pairwise, scan, skipAlreadyAppeared, skipUnchanged, skip, skipWhile, startWith, switchMap, take, takeWhile, terminateBy, throttle, withLatest, withInitialValue, } from './internal/RN'; | ||
export { auditTime, debounce, delay, filter, flatMap, map, mapTo, valueIs, valueIsNot, withTimestamp, pluck, pairwise, scan, skipAlreadyAppeared, skipUnchanged, skip, skipWhile, startWith, switchMap, take, takeWhile, takeUntil, terminateBy, throttle, withLatest, withInitialValue, } from './internal/RN'; |
@@ -25,2 +25,3 @@ "use strict"; | ||
exports.takeWhile = RN_1.takeWhile; | ||
exports.takeUntil = RN_1.takeUntil; | ||
exports.terminateBy = RN_1.terminateBy; | ||
@@ -27,0 +28,0 @@ exports.throttle = RN_1.throttle; |
@@ -15,2 +15,3 @@ "use strict"; | ||
intv.listenUntil(terminator, true, v => console.log(v), undefined, () => console.log('end')); | ||
setTimeout(() => { intv.stop(); }, 3000); | ||
// Mutation is not | ||
@@ -17,0 +18,0 @@ // foo.bar = 456; |
@@ -6,3 +6,3 @@ { | ||
"name": "rnjs", | ||
"version": "1.0.23", | ||
"version": "1.0.24", | ||
"description": "Reactive Programming Library for TypeScript/JavaScript", | ||
@@ -9,0 +9,0 @@ "main": "dist/index.js", |
@@ -51,3 +51,3 @@ import { RNId } from './types/RNId'; | ||
this.parentsInternal = parents; | ||
this.parents.forEach( src => src.addChild( this ) ); | ||
this.parents.forEach( src => src.addChild(this) ); | ||
@@ -69,5 +69,5 @@ this.priority = 1 + this.parents.reduce( | ||
private static addTasks( rns: RN<any>[] ) { | ||
private static addTasks(rns: RN<any>[]) { | ||
if ( !rns || rns.length === 0 ) return; | ||
rns.forEach( rn => this.addAsHeapUniq( rn ) ); | ||
rns.forEach( rn => this.addAsHeapUniq(rn) ); | ||
if ( !this.engine.doTaskIsRunning ) this.doTask(); | ||
@@ -87,15 +87,15 @@ } | ||
private static exists( newValue: RN<any> ): boolean { | ||
return ( this.engine.priorityQueue.findIndex( e => e.id === newValue.id ) !== -1 ); | ||
private static exists(newValue: RN<any>): boolean { | ||
return (this.engine.priorityQueue.findIndex(e => e.id === newValue.id) !== -1); | ||
} | ||
private static addAsHeapUniq( newValue: RN<any> ) { | ||
if ( !this.exists( newValue ) ) { | ||
this.addAsHeap( newValue ); | ||
private static addAsHeapUniq(newValue: RN<any>) { | ||
if ( !this.exists(newValue) ) { | ||
this.addAsHeap(newValue); | ||
} | ||
} | ||
private static addAsHeap( newValue: RN<any> ) { | ||
private static addAsHeap(newValue: RN<any>) { | ||
const heap = this.engine.priorityQueue; | ||
heap.push( newValue ); | ||
heap.push(newValue); | ||
if ( heap.length <= 1 ) return; | ||
@@ -166,10 +166,10 @@ | ||
private addChild( c: RN<any> ) { | ||
private addChild(c: RN<any>) { | ||
if ( !c ) return; | ||
this.children.push( c ); | ||
this.children.push(c); | ||
} | ||
private addSubscriber( s: Subscriber<T> ) { | ||
private addSubscriber(s: Subscriber<T>) { | ||
// return the index of added subscriber | ||
return this.subscribers.push( s ) - 1; | ||
return this.subscribers.push(s) - 1; | ||
} | ||
@@ -181,3 +181,3 @@ | ||
protected fireWith( v: T ) { | ||
protected fireWith(v: T) { | ||
if ( this.isCompleted ) return; | ||
@@ -189,6 +189,6 @@ | ||
// run subscribers for the current value | ||
this.subscribers.forEach( s => { s.next( this.value ); }); | ||
this.subscribers.forEach(s => { s.next( this.value ); }); | ||
// propagate to children | ||
RN.addTasks( this.children ); | ||
RN.addTasks(this.children); | ||
} | ||
@@ -214,7 +214,7 @@ | ||
&& | ||
this.parents.every( r => r.isCompleted ) | ||
this.parents.every(r => r.isCompleted) | ||
) || ( | ||
this.subscribers.length === 0 | ||
&& | ||
this.children.every( r => r.isCompleted ) | ||
this.children.every(r => r.isCompleted) | ||
) | ||
@@ -232,6 +232,6 @@ ) { | ||
this.promiseResolver( this.value ); | ||
this.promiseResolver(this.value); | ||
// run subscribers for the current value | ||
this.subscribers.forEach( s => { s.complete( this.value ); }); | ||
this.subscribers.forEach(s => { s.complete(this.value); }); | ||
@@ -242,6 +242,6 @@ // remove all subscribers | ||
// propagate to children | ||
this.children.forEach( rn => { rn.askIfComplete(); }); | ||
this.children.forEach(rn => { rn.askIfComplete(); }); | ||
// propagate to parents | ||
this.parents.forEach( rn => { rn.askIfComplete(); }); | ||
// this.parents.forEach( rn => { rn.askIfComplete(); }); | ||
} | ||
@@ -259,3 +259,3 @@ | ||
// run subscribers for the current value | ||
this.subscribers.forEach( s => { s.error( this.value ); }); | ||
this.subscribers.forEach(s => { s.error( this.value ); }); | ||
@@ -266,6 +266,6 @@ // remove all subscribers | ||
// propagate to children | ||
this.children.forEach( rn => { rn.completeWithError(); }); | ||
this.children.forEach(rn => { rn.completeWithError(); }); | ||
// propagate to parents | ||
this.parents.forEach( rn => { rn.askIfComplete(); }); | ||
// this.parents.forEach( rn => { rn.askIfComplete(); }); | ||
} | ||
@@ -283,3 +283,3 @@ | ||
): Subscription { | ||
return this.subscribe( onFire, onError, onComplete, runWithFirstValue ); | ||
return this.subscribe(onFire, onError, onComplete, runWithFirstValue); | ||
} | ||
@@ -372,3 +372,3 @@ | ||
): Subscription { | ||
return this.terminateBy( terminator ) | ||
return this.takeUntil( terminator ) | ||
.listen( runWithFirstValue, onFire, onError, onComplete ); | ||
@@ -472,12 +472,12 @@ } | ||
auditTime( time: number ): RN<T> { | ||
return auditTime<T>( time )( this ); | ||
auditTime(time: number): RN<T> { | ||
return auditTime<T>(time)(this); | ||
} | ||
debounce( time: number ): RN<T> { | ||
return debounce<T>( time )( this ); | ||
debounce(time: number): RN<T> { | ||
return debounce<T>(time)(this); | ||
} | ||
delay( time: number ): RN<T> { | ||
return delay<T>( time )( this ); | ||
delay(time: number): RN<T> { | ||
return delay<T>(time)(this); | ||
} | ||
@@ -489,3 +489,3 @@ | ||
): RN<T> { | ||
return filter<T>( initialValue, predicate )( this ); | ||
return filter<T>(initialValue, predicate)(this); | ||
} | ||
@@ -496,3 +496,3 @@ | ||
): RN<U> { | ||
return flatMap<T, U>( fn )( this ); | ||
return flatMap<T, U>(fn)(this); | ||
} | ||
@@ -503,27 +503,27 @@ | ||
): RN<U> { | ||
return map<T, U>( fn )( this ); | ||
return map<T, U>(fn)(this); | ||
} | ||
mapTo<U>( value: U ): RN<U> { | ||
return mapTo<T, U>( value )( this ); | ||
mapTo<U>(value: U): RN<U> { | ||
return mapTo<T, U>(value)(this); | ||
} | ||
valueIs( value: T ): RN<boolean> { | ||
return valueIs<T>( value )( this ); | ||
valueIs(value: T): RN<boolean> { | ||
return valueIs<T>(value)(this); | ||
} | ||
valueIsNot( value: T ): RN<boolean> { | ||
return valueIsNot<T>( value )( this ); | ||
valueIsNot(value: T): RN<boolean> { | ||
return valueIsNot<T>(value)(this); | ||
} | ||
pluck<K extends keyof T>( member: K ): RN<T[K]> { | ||
return pluck<T, K>( member )( this ); | ||
pluck<K extends keyof T>(member: K): RN<T[K]> { | ||
return pluck<T, K>(member)(this); | ||
} | ||
withTimestamp(): RN<[T, number]> { | ||
return withTimestamp<T>()( this ); | ||
return withTimestamp<T>()(this); | ||
} | ||
pairwise( initialPrevValue?: T ): RN<[T, T]> { | ||
return pairwise<T>( initialPrevValue )( this ); | ||
pairwise(initialPrevValue?: T): RN<[T, T]> { | ||
return pairwise<T>(initialPrevValue)(this); | ||
} | ||
@@ -535,7 +535,7 @@ | ||
): RN<U> { | ||
return scan<T, U>( initialValue, fn )( this ); | ||
return scan<T, U>(initialValue, fn)(this); | ||
} | ||
skip( initialValue: T, skipNum: number ): RN<T> { | ||
return skip<T>( initialValue, skipNum )( this ); | ||
skip(initialValue: T, skipNum: number): RN<T> { | ||
return skip<T>(initialValue, skipNum)(this); | ||
} | ||
@@ -547,15 +547,15 @@ | ||
): RN<T> { | ||
return skipWhile<T>( initialValue, predicate )( this ); | ||
return skipWhile<T>(initialValue, predicate)(this); | ||
} | ||
skipAlreadyAppeared<K extends keyof T>( key?: K ): RN<T> { | ||
return skipAlreadyAppeared<T, K>( key )( this ); | ||
return skipAlreadyAppeared<T, K>(key)(this); | ||
} | ||
skipUnchanged( eq?: (a: T, b: T) => boolean ): RN<T> { | ||
return skipUnchanged<T>( eq )( this ); | ||
skipUnchanged(eq?: (a: T, b: T) => boolean): RN<T> { | ||
return skipUnchanged<T>(eq)(this); | ||
} | ||
startWith( initialValue: T ): RN<T> { | ||
return startWith( initialValue )( this ); | ||
startWith(initialValue: T): RN<T> { | ||
return startWith(initialValue)(this); | ||
} | ||
@@ -566,7 +566,7 @@ | ||
): RN<U> { | ||
return switchMap<T, U>( fn )( this ); | ||
return switchMap<T, U>(fn)(this); | ||
} | ||
take( takeNum: number ): RN<T> { | ||
return take<T>( takeNum )( this ); | ||
take(takeNum: number): RN<T> { | ||
return take<T>(takeNum)(this); | ||
} | ||
@@ -577,19 +577,22 @@ | ||
): RN<T> { | ||
return takeWhile<T>( predicate )( this ); | ||
return takeWhile<T>(predicate)(this); | ||
} | ||
takeUntil(terminator: RN<void>): RN<T> { | ||
return takeUntil<T>(terminator)(this); | ||
} | ||
terminateBy(terminator: RN<void>): RN<T> { | ||
return terminateBy<T>( terminator )( this ); | ||
return takeUntil<T>(terminator)(this); | ||
} | ||
throttle( time: number ): RN<T> { | ||
return throttle<T>( time )( this ); | ||
throttle(time: number): RN<T> { | ||
return throttle<T>(time)(this); | ||
} | ||
withInitialValue( initialValue: T ): RN<T> { | ||
return withInitialValue( initialValue )( this ); | ||
withInitialValue(initialValue: T): RN<T> { | ||
return withInitialValue(initialValue)(this); | ||
} | ||
withLatest<U>( src: RN<U> ): RN<[T, U]> { | ||
return withLatest<T, U>( src )( this ); | ||
withLatest<U>(src: RN<U>): RN<[T, U]> { | ||
return withLatest<T, U>(src)(this); | ||
} | ||
@@ -624,3 +627,3 @@ | ||
complete() { | ||
protected complete() { | ||
super.complete(); | ||
@@ -653,3 +656,3 @@ clearTimeout( this.timerId ); | ||
complete() { | ||
protected complete() { | ||
super.complete(); | ||
@@ -680,3 +683,3 @@ clearTimeout( this.timerId ); | ||
complete() { | ||
protected complete() { | ||
super.complete(); | ||
@@ -748,3 +751,3 @@ clearTimeout( this.timerId ); | ||
complete() { | ||
protected complete() { | ||
super.complete(); | ||
@@ -913,3 +916,3 @@ this.subscriptions.forEach( s => s.unsubscribe() ); | ||
complete() { | ||
protected complete() { | ||
super.complete(); | ||
@@ -998,3 +1001,3 @@ this.appeared.clear(); | ||
complete() { | ||
protected complete() { | ||
super.complete(); | ||
@@ -1042,10 +1045,10 @@ this.subscription.unsubscribe(); | ||
export const terminateBy = <T>(terminator: RN<void>): Operator<T, T> => | ||
(( src: RN<T> ) => new TerminateByRN<T>(src, terminator)); | ||
(( src: RN<T> ) => new TakeUntilRN<T>(src, terminator)); | ||
export const takeUntil = <T>(terminator: RN<void>): Operator<T, T> => | ||
(( src: RN<T> ) => new TerminateByRN<T>(src, terminator)); | ||
(( src: RN<T> ) => new TakeUntilRN<T>(src, terminator)); | ||
class TerminateByRN<T> extends RN<T> { | ||
class TakeUntilRN<T> extends RN<T> { | ||
private readonly subscription: Subscription; | ||
@@ -1058,3 +1061,4 @@ | ||
super( src.value, [src] ); | ||
this.subscription = terminator.listen( false, () => {}, () => {}, () => this.terminate() ); | ||
const terminate = () => this.complete(); | ||
this.subscription = terminator.listen(false, terminate, () => {}, terminate); | ||
} | ||
@@ -1067,3 +1071,3 @@ | ||
complete() { | ||
protected complete() { | ||
super.complete(); | ||
@@ -1070,0 +1074,0 @@ this.subscription.unsubscribe(); |
@@ -37,3 +37,3 @@ import { RN } from '../RN'; | ||
complete() { | ||
protected complete() { | ||
super.complete(); | ||
@@ -40,0 +40,0 @@ clearInterval( this.timerId ); |
@@ -23,2 +23,3 @@ export { | ||
takeWhile, | ||
takeUntil, | ||
terminateBy, | ||
@@ -25,0 +26,0 @@ throttle, |
@@ -26,2 +26,3 @@ import { | ||
setTimeout(() => { intv.stop(); }, 3000); | ||
@@ -28,0 +29,0 @@ // Mutation is not |
218525
5679