@typeheim/fire-rx
Advanced tools
Comparing version 0.0.5 to 0.0.6
export * from './src/Contracts/Observables'; | ||
export * from './src/Decorators/OnDestroyHooks'; | ||
export * from './src/Observables/AggregateStream'; | ||
export * from './src/Observables/DestroyEvent'; | ||
export * from './src/Observables/ReactivePromise'; | ||
export * from './src/Observables/ReactiveStream'; | ||
export * from './src/Observables/ReadonlyStream'; | ||
export * from './src/Observables/StatefulProducer'; | ||
export * from './src/Observables/StatefulStream'; | ||
export * from './src/Observables/StatefulSubject'; | ||
@@ -8,0 +10,0 @@ export * from './src/Observables/ValueSubject'; |
@@ -15,6 +15,8 @@ "use strict"; | ||
__exportStar(require("./src/Decorators/OnDestroyHooks"), exports); | ||
__exportStar(require("./src/Observables/AggregateStream"), exports); | ||
__exportStar(require("./src/Observables/DestroyEvent"), exports); | ||
__exportStar(require("./src/Observables/ReactivePromise"), exports); | ||
__exportStar(require("./src/Observables/ReactiveStream"), exports); | ||
__exportStar(require("./src/Observables/ReadonlyStream"), exports); | ||
__exportStar(require("./src/Observables/StatefulProducer"), exports); | ||
__exportStar(require("./src/Observables/StatefulStream"), exports); | ||
__exportStar(require("./src/Observables/StatefulSubject"), exports); | ||
@@ -21,0 +23,0 @@ __exportStar(require("./src/Observables/ValueSubject"), exports); |
{ | ||
"name": "@typeheim/fire-rx", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "RxJS on steroids", | ||
@@ -32,3 +32,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "d6fc319d4c3b96a2974ec396373a701856a10bbe" | ||
"gitHead": "752416a757d3891070f31002a93e5817c48437f6" | ||
} |
import { Subscribable } from 'rxjs'; | ||
import { ReadonlyStream } from '../Observables/ReadonlyStream'; | ||
export interface Producer<T> extends Subscribable<T> { | ||
/** | ||
* @deprecated | ||
*/ | ||
export interface Producer<T> extends Publisher<T> { | ||
} | ||
export interface Publisher<T> extends Subscribable<T> { | ||
isStopped: boolean; | ||
hasError: boolean; | ||
closed: boolean; | ||
/** | ||
@@ -10,6 +17,2 @@ * Subscribe to a destruction event to complete and unsubscribe as it | ||
/** | ||
* Create readonly stream with this producer as source | ||
*/ | ||
toReadonlyStream(): ReadonlyStream<T>; | ||
/** | ||
* Completes producer and clean up resources | ||
@@ -22,2 +25,22 @@ */ | ||
fail(error: any): void; | ||
/** | ||
* Attaches callbacks for the resolution and/or rejection of the Promise. | ||
* @param onfulfilled The callback to execute when the Promise is resolved. | ||
* @param onrejected The callback to execute when the Promise is rejected. | ||
* @returns A Promise for the completion of which ever callback is executed. | ||
*/ | ||
then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<TResult1 | TResult2>; | ||
/** | ||
* Attaches a callback for only the rejection of the Promise. | ||
* @param onrejected The callback to execute when the Promise is rejected. | ||
* @returns A Promise for the completion of the callback. | ||
*/ | ||
catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null): Promise<T | TResult>; | ||
/** | ||
* Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The | ||
* resolved value cannot be modified from the callback. | ||
* @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected). | ||
* @returns A Promise for the completion of the callback. | ||
*/ | ||
finally(onfinally?: (() => void) | undefined | null): Promise<T>; | ||
} | ||
@@ -24,0 +47,0 @@ export interface Observer<T> { |
import { Observable } from 'rxjs'; | ||
/** | ||
* @deprecated in favour for { ReactiveStream } | ||
*/ | ||
export declare class ReadonlyStream<T> extends Observable<T> { | ||
@@ -3,0 +6,0 @@ /** |
@@ -5,2 +5,5 @@ "use strict"; | ||
const rxjs_1 = require("rxjs"); | ||
/** | ||
* @deprecated in favour for { ReactiveStream } | ||
*/ | ||
class ReadonlyStream extends rxjs_1.Observable { | ||
@@ -7,0 +10,0 @@ /** |
import { SchedulerLike, ReplaySubject, Subscription } from 'rxjs'; | ||
import { ReadonlyStream } from './ReadonlyStream'; | ||
import { Producer } from '../Contracts/Observables'; | ||
import { Publisher } from '../Contracts/Observables'; | ||
import { Subscribable } from '../Contracts/RxJsInternals'; | ||
export declare class StatefulSubject<T> extends ReplaySubject<T> implements Producer<T> { | ||
import { ReactiveStream } from './ReactiveStream'; | ||
export declare class StatefulSubject<T> extends ReplaySubject<T> implements Publisher<T> { | ||
protected _internalPromise: Promise<T>; | ||
protected promiseSubscription: Subscription; | ||
protected _emitsCount: number; | ||
@@ -22,6 +24,10 @@ protected hub: Subscription; | ||
/** | ||
* Create readonly stream with this subject as source | ||
* @deprecated | ||
*/ | ||
toReadonlyStream(): ReadonlyStream<T>; | ||
/** | ||
* Create readonly stream with this subject as source | ||
*/ | ||
toStream(): ReactiveStream<T>; | ||
/** | ||
* Completes subject and clean up resources | ||
@@ -35,2 +41,3 @@ */ | ||
protected get internalPromise(): Promise<T>; | ||
protected clearInternalPromise(): void; | ||
/** | ||
@@ -37,0 +44,0 @@ * Attaches callbacks for the resolution and/or rejection of the Promise. |
@@ -6,2 +6,3 @@ "use strict"; | ||
const ReadonlyStream_1 = require("./ReadonlyStream"); | ||
const ReactiveStream_1 = require("./ReactiveStream"); | ||
class StatefulSubject extends rxjs_1.ReplaySubject { | ||
@@ -39,3 +40,3 @@ constructor(bufferSize = 1, windowTime = Number.POSITIVE_INFINITY, scheduler) { | ||
/** | ||
* Create readonly stream with this subject as source | ||
* @deprecated | ||
*/ | ||
@@ -48,2 +49,8 @@ toReadonlyStream() { | ||
/** | ||
* Create readonly stream with this subject as source | ||
*/ | ||
toStream() { | ||
return new ReactiveStream_1.ReactiveStream(this); | ||
} | ||
/** | ||
* Completes subject and clean up resources | ||
@@ -60,3 +67,3 @@ */ | ||
this.hub.unsubscribe(); | ||
this._internalPromise = null; | ||
this.clearInternalPromise(); | ||
} | ||
@@ -79,7 +86,7 @@ /** | ||
this._internalPromise = new Promise((resolve, reject) => { | ||
this.subscribe({ | ||
this.promiseSubscription = this.subscribe({ | ||
next: (data) => { | ||
lastValue = data; | ||
// promise should return only one value and then being destroyed | ||
this._internalPromise = null; | ||
this.clearInternalPromise(); | ||
resolve(data); | ||
@@ -89,3 +96,3 @@ }, | ||
// promise should return only one value and then being destroyed | ||
this._internalPromise = null; | ||
this.clearInternalPromise(); | ||
reject(error); | ||
@@ -95,3 +102,3 @@ }, | ||
// promise should return only one value and then being destroyed | ||
this._internalPromise = null; | ||
this.clearInternalPromise(); | ||
resolve(lastValue); | ||
@@ -104,2 +111,9 @@ }, | ||
} | ||
clearInternalPromise() { | ||
this._internalPromise = null; | ||
if (this.promiseSubscription) { | ||
this.promiseSubscription.unsubscribe(); | ||
this.promiseSubscription = null; | ||
} | ||
} | ||
/** | ||
@@ -106,0 +120,0 @@ * Attaches callbacks for the resolution and/or rejection of the Promise. |
import { BehaviorSubject, Subscribable, Subscription } from 'rxjs'; | ||
import { ReadonlyStream } from './ReadonlyStream'; | ||
export declare class ValueSubject<T> extends BehaviorSubject<T> { | ||
import { Publisher } from '../..'; | ||
import { ReactiveStream } from './ReactiveStream'; | ||
export declare class ValueSubject<T> extends BehaviorSubject<T> implements Publisher<T> { | ||
protected _internalPromise: Promise<T>; | ||
protected promiseSubscription: Subscription; | ||
protected _emitsCount: number; | ||
@@ -23,4 +26,12 @@ protected hub: Subscription; | ||
fail(error: any): void; | ||
/** | ||
* @deprecated | ||
*/ | ||
toReadonlyStream(): ReadonlyStream<T>; | ||
/** | ||
* Create readonly stream with this subject as source | ||
*/ | ||
toStream(): ReactiveStream<T>; | ||
protected get internalPromise(): Promise<T>; | ||
protected clearInternalPromise(): void; | ||
/** | ||
@@ -27,0 +38,0 @@ * Attaches callbacks for the resolution and/or rejection of the Promise. |
@@ -6,2 +6,3 @@ "use strict"; | ||
const ReadonlyStream_1 = require("./ReadonlyStream"); | ||
const ReactiveStream_1 = require("./ReactiveStream"); | ||
class ValueSubject extends rxjs_1.BehaviorSubject { | ||
@@ -47,3 +48,3 @@ constructor() { | ||
this.hub.unsubscribe(); | ||
this._internalPromise = null; | ||
this.clearInternalPromise(); | ||
} | ||
@@ -59,3 +60,7 @@ /** | ||
} | ||
this.clearInternalPromise(); | ||
} | ||
/** | ||
* @deprecated | ||
*/ | ||
toReadonlyStream() { | ||
@@ -66,2 +71,8 @@ const observable = new ReadonlyStream_1.ReadonlyStream(); | ||
} | ||
/** | ||
* Create readonly stream with this subject as source | ||
*/ | ||
toStream() { | ||
return new ReactiveStream_1.ReactiveStream(this); | ||
} | ||
// | ||
@@ -76,7 +87,7 @@ // Promise interface | ||
this._internalPromise = new Promise((resolve, reject) => { | ||
this.subscribe({ | ||
this.promiseSubscription = this.subscribe({ | ||
next: (data) => { | ||
lastValue = data; | ||
// promise should return only one value and then being destroyed | ||
this._internalPromise = null; | ||
this.clearInternalPromise(); | ||
resolve(data); | ||
@@ -86,3 +97,3 @@ }, | ||
// promise should return only one value and then being destroyed | ||
this._internalPromise = null; | ||
this.clearInternalPromise(); | ||
reject(error); | ||
@@ -92,3 +103,3 @@ }, | ||
// promise should return only one value and then being destroyed | ||
this._internalPromise = null; | ||
this.clearInternalPromise(); | ||
resolve(lastValue); | ||
@@ -101,2 +112,9 @@ }, | ||
} | ||
clearInternalPromise() { | ||
this._internalPromise = null; | ||
if (this.promiseSubscription) { | ||
this.promiseSubscription.unsubscribe(); | ||
this.promiseSubscription = null; | ||
} | ||
} | ||
/** | ||
@@ -103,0 +121,0 @@ * Attaches callbacks for the resolution and/or rejection of the Promise. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
66314
45
1165