@typeheim/fire-rx
Advanced tools
Comparing version 0.0.0-beta.16 to 0.0.0-beta.17
{ | ||
"name": "@typeheim/fire-rx", | ||
"version": "0.0.0-beta.16", | ||
"version": "0.0.0-beta.17", | ||
"description": "Firebase authentication library", | ||
@@ -32,3 +32,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "175283382a85817e53cd6f463a5784c736a5c130" | ||
"gitHead": "ca1636ae2e6347d6aeb9c2911e168e2539dcbc6a" | ||
} |
@@ -39,1 +39,2 @@ /** OBSERVABLE INTERFACES */ | ||
} | ||
export declare type TeardownLogic = Unsubscribable | Function | void; |
@@ -1,2 +0,3 @@ | ||
import { ReactivePromise } from './ReactivePromise'; | ||
import { ReplaySubject } from 'rxjs'; | ||
import { SubscriptionsHub } from './SubscriptionsHub'; | ||
/** | ||
@@ -6,4 +7,9 @@ * Special type of subject that should be used in pair with `until` method of | ||
*/ | ||
export declare class DestroyEvent extends ReactivePromise<boolean> { | ||
export declare class DestroyEvent extends ReplaySubject<boolean> { | ||
protected hub: SubscriptionsHub; | ||
/** | ||
* @deprecated internal method | ||
*/ | ||
_subscribe(subscriber: any): import("rxjs").Subscription; | ||
emit(): void; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const ReactivePromise_1 = require("./ReactivePromise"); | ||
const rxjs_1 = require("rxjs"); | ||
const SubscriptionsHub_1 = require("./SubscriptionsHub"); | ||
/** | ||
@@ -8,5 +9,19 @@ * Special type of subject that should be used in pair with `until` method of | ||
*/ | ||
class DestroyEvent extends ReactivePromise_1.ReactivePromise { | ||
class DestroyEvent extends rxjs_1.ReplaySubject { | ||
constructor() { | ||
super(...arguments); | ||
this.hub = new SubscriptionsHub_1.SubscriptionsHub(); | ||
} | ||
/** | ||
* @deprecated internal method | ||
*/ | ||
_subscribe(subscriber) { | ||
let sub = super._subscribe(subscriber); | ||
this.hub.add(sub); | ||
return sub; | ||
} | ||
emit() { | ||
this.resolve(true); | ||
this.next(true); | ||
this.complete(); | ||
this.hub.unsubscribe(); | ||
} | ||
@@ -13,0 +28,0 @@ } |
import { ReplaySubject, Subscribable } from 'rxjs'; | ||
import { Unsubscribable, PartialObserver } from './contracts'; | ||
import { PartialObserver, SubscriptionLike } from './contracts'; | ||
import { SubscriptionsHub } from './SubscriptionsHub'; | ||
/** Symbol.observable or a string "@@observable". Used for interop */ | ||
export declare const observable: string | symbol; | ||
export declare class ReactivePromise<T> implements Subscribable<T> { | ||
@@ -19,11 +21,8 @@ protected internalPromise: Promise<T>; | ||
*/ | ||
emitUntil(destroyEvent: Subscribable<any>): this; | ||
/** | ||
* @depreacted | ||
*/ | ||
until(destroyEvent: Subscribable<any>): this; | ||
subscribe(observer?: PartialObserver<T>): Unsubscribable; | ||
/** @deprecated Use an observer instead of a complete callback */ | ||
subscribe(next: null | undefined, error: null | undefined, complete: () => void): Unsubscribable; | ||
/** @deprecated Use an observer instead of an error callback */ | ||
subscribe(next: null | undefined, error: (error: any) => void, complete?: () => void): Unsubscribable; | ||
/** @deprecated Use an observer instead of a complete callback */ | ||
subscribe(next: (value: T) => void, error: null | undefined, complete: () => void): Unsubscribable; | ||
subscribe(next?: (value: T) => void, error?: (error: any) => void, complete?: () => void): Unsubscribable; | ||
subscribe(observerOrNext?: PartialObserver<T> | ((value: T) => void), error?: (error: any) => void, complete?: () => void): SubscriptionLike; | ||
pipe(...operators: any): any; | ||
@@ -30,0 +29,0 @@ /** |
@@ -5,2 +5,4 @@ "use strict"; | ||
const SubscriptionsHub_1 = require("./SubscriptionsHub"); | ||
/** Symbol.observable or a string "@@observable". Used for interop */ | ||
exports.observable = (() => typeof Symbol === 'function' && Symbol.observable || '@@observable')(); | ||
class ReactivePromise { | ||
@@ -51,3 +53,3 @@ constructor(executor) { | ||
*/ | ||
until(destroyEvent) { | ||
emitUntil(destroyEvent) { | ||
destroyEvent.subscribe(() => { | ||
@@ -61,2 +63,13 @@ if (!this.resolved) { | ||
} | ||
/** | ||
* @depreacted | ||
*/ | ||
until(destroyEvent) { | ||
return this.emitUntil(destroyEvent); | ||
} | ||
// | ||
// | ||
// SUBJECT INTERFACE | ||
// | ||
// | ||
subscribe(observerOrNext, error, complete) { | ||
@@ -74,2 +87,8 @@ // @ts-ignore | ||
} | ||
/** | ||
* An interop point defined by the es7-observable spec https://github.com/zenparsing/es-observable | ||
*/ | ||
[exports.observable]() { | ||
return this; | ||
} | ||
// | ||
@@ -76,0 +95,0 @@ // |
import { ReplaySubject } from 'rxjs'; | ||
import { Subscribable } from './contracts'; | ||
import { SubscriptionsHub } from './SubscriptionsHub'; | ||
export declare class StatefulSubject<T> extends ReplaySubject<T> implements PromiseLike<T> { | ||
protected _internalPromise: Promise<T>; | ||
protected promiseSubscription: any; | ||
protected _emitsCount: number; | ||
protected hub: SubscriptionsHub; | ||
get emitsCount(): number; | ||
next(value?: T): void; | ||
get internalPromise(): Promise<T>; | ||
protected get internalPromise(): Promise<T>; | ||
/** | ||
* @deprecated internal method | ||
*/ | ||
_subscribe(subscriber: any): import("rxjs").Subscription; | ||
/** | ||
* Subscribe to a destruction event to complete and unsubscribe as it | ||
* emits | ||
*/ | ||
emitUntil(destroyEvent: Subscribable<any>): this; | ||
/** | ||
* @deprecated | ||
*/ | ||
until(destroyEvent: Subscribable<any>): this; | ||
/** | ||
* Completes subject and clean up resources | ||
*/ | ||
close(): void; | ||
/** | ||
* Attaches callbacks for the resolution and/or rejection of the Promise. | ||
@@ -17,0 +30,0 @@ * @param onfulfilled The callback to execute when the Promise is resolved. |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const rxjs_1 = require("rxjs"); | ||
const SubscriptionsHub_1 = require("./SubscriptionsHub"); | ||
class StatefulSubject extends rxjs_1.ReplaySubject { | ||
@@ -8,2 +9,3 @@ constructor() { | ||
this._emitsCount = 0; | ||
this.hub = new SubscriptionsHub_1.SubscriptionsHub(); | ||
} | ||
@@ -23,21 +25,19 @@ get emitsCount() { | ||
this._internalPromise = new Promise((resolve, reject) => { | ||
this.promiseSubscription = this.subscribe((data) => { | ||
var _a; | ||
lastValue = data; | ||
// promise should return only one value and then being destroyed | ||
this._internalPromise = null; | ||
(_a = this.promiseSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe(); | ||
resolve(data); | ||
}, error => { | ||
var _a; | ||
// promise should return only one value and then being destroyed | ||
this._internalPromise = null; | ||
(_a = this.promiseSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe(); | ||
reject(error); | ||
}, () => { | ||
var _a; | ||
// promise should return only one value and then being destroyed | ||
this._internalPromise = null; | ||
(_a = this.promiseSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe(); | ||
resolve(lastValue); | ||
this.subscribe({ | ||
next: (data) => { | ||
lastValue = data; | ||
// promise should return only one value and then being destroyed | ||
this._internalPromise = null; | ||
resolve(data); | ||
}, | ||
error: (error) => { | ||
// promise should return only one value and then being destroyed | ||
this._internalPromise = null; | ||
reject(error); | ||
}, | ||
complete: () => { | ||
// promise should return only one value and then being destroyed | ||
this._internalPromise = null; | ||
resolve(lastValue); | ||
}, | ||
}); | ||
@@ -49,13 +49,16 @@ }); | ||
/** | ||
* @deprecated internal method | ||
*/ | ||
_subscribe(subscriber) { | ||
let sub = super._subscribe(subscriber); | ||
this.hub.add(sub); | ||
return sub; | ||
} | ||
/** | ||
* Subscribe to a destruction event to complete and unsubscribe as it | ||
* emits | ||
*/ | ||
until(destroyEvent) { | ||
emitUntil(destroyEvent) { | ||
destroyEvent.subscribe(() => { | ||
var _a; | ||
this._internalPromise = null; | ||
(_a = this.promiseSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe(); | ||
this.promiseSubscription = null; | ||
this.complete(); | ||
this.unsubscribe(); | ||
this.close(); | ||
}); | ||
@@ -65,2 +68,16 @@ return this; | ||
/** | ||
* @deprecated | ||
*/ | ||
until(destroyEvent) { | ||
return this.emitUntil(destroyEvent); | ||
} | ||
/** | ||
* Completes subject and clean up resources | ||
*/ | ||
close() { | ||
this._internalPromise = null; | ||
this.complete(); | ||
this.hub.unsubscribe(); | ||
} | ||
/** | ||
* Attaches callbacks for the resolution and/or rejection of the Promise. | ||
@@ -67,0 +84,0 @@ * @param onfulfilled The callback to execute when the Promise is resolved. |
@@ -21,3 +21,9 @@ "use strict"; | ||
this.subscriptions.forEach(subscription => { | ||
subscription.unsubscribe(); | ||
if (subscription['closed'] !== undefined && !subscription['closed']) { | ||
subscription.unsubscribe(); | ||
} | ||
else { | ||
// @todo - figure out a better way to prevent duplication | ||
subscription.unsubscribe(); | ||
} | ||
}); | ||
@@ -24,0 +30,0 @@ this.subscriptions = []; |
import { BehaviorSubject, Subscribable } from 'rxjs'; | ||
import { SubscriptionsHub } from './SubscriptionsHub'; | ||
export declare class ValueSubject<T> extends BehaviorSubject<T> { | ||
protected _internalPromise: Promise<T>; | ||
protected promiseSubscription: any; | ||
protected _emitsCount: number; | ||
protected hub: SubscriptionsHub; | ||
get emitsCount(): number; | ||
next(value: T): void; | ||
get internalPromise(): Promise<T>; | ||
next(value?: T): void; | ||
protected get internalPromise(): Promise<T>; | ||
/** | ||
* @deprecated internal method | ||
*/ | ||
_subscribe(subscriber: any): import("rxjs").Subscription; | ||
/** | ||
* Subscribe to a destruction event to complete and unsubscribe as it | ||
* emits | ||
*/ | ||
until(destroyEvent: Subscribable<T>): this; | ||
emitUntil(destroyEvent: Subscribable<any>): this; | ||
/** | ||
* @deprecated | ||
*/ | ||
until(destroyEvent: Subscribable<any>): this; | ||
/** | ||
* Completes subject and clean up resources | ||
*/ | ||
close(): void; | ||
/** | ||
* Attaches callbacks for the resolution and/or rejection of the Promise. | ||
@@ -16,0 +29,0 @@ * @param onfulfilled The callback to execute when the Promise is resolved. |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const rxjs_1 = require("rxjs"); | ||
const SubscriptionsHub_1 = require("./SubscriptionsHub"); | ||
class ValueSubject extends rxjs_1.BehaviorSubject { | ||
@@ -8,2 +9,3 @@ constructor() { | ||
this._emitsCount = 0; | ||
this.hub = new SubscriptionsHub_1.SubscriptionsHub(); | ||
} | ||
@@ -23,21 +25,19 @@ get emitsCount() { | ||
this._internalPromise = new Promise((resolve, reject) => { | ||
this.promiseSubscription = this.subscribe((data) => { | ||
var _a; | ||
lastValue = data; | ||
// promise should return only one value and then being destroyed | ||
this._internalPromise = null; | ||
(_a = this.promiseSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe(); | ||
resolve(data); | ||
}, error => { | ||
var _a; | ||
// promise should return only one value and then being destroyed | ||
this._internalPromise = null; | ||
(_a = this.promiseSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe(); | ||
reject(error); | ||
}, () => { | ||
var _a; | ||
// promise should return only one value and then being destroyed | ||
this._internalPromise = null; | ||
(_a = this.promiseSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe(); | ||
resolve(lastValue); | ||
this.subscribe({ | ||
next: (data) => { | ||
lastValue = data; | ||
// promise should return only one value and then being destroyed | ||
this._internalPromise = null; | ||
resolve(data); | ||
}, | ||
error: (error) => { | ||
// promise should return only one value and then being destroyed | ||
this._internalPromise = null; | ||
reject(error); | ||
}, | ||
complete: () => { | ||
// promise should return only one value and then being destroyed | ||
this._internalPromise = null; | ||
resolve(lastValue); | ||
}, | ||
}); | ||
@@ -49,13 +49,16 @@ }); | ||
/** | ||
* @deprecated internal method | ||
*/ | ||
_subscribe(subscriber) { | ||
let sub = super._subscribe(subscriber); | ||
this.hub.add(sub); | ||
return sub; | ||
} | ||
/** | ||
* Subscribe to a destruction event to complete and unsubscribe as it | ||
* emits | ||
*/ | ||
until(destroyEvent) { | ||
emitUntil(destroyEvent) { | ||
destroyEvent.subscribe(() => { | ||
var _a; | ||
this._internalPromise = null; | ||
(_a = this.promiseSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe(); | ||
this.promiseSubscription = null; | ||
this.complete(); | ||
this.unsubscribe(); | ||
this.close(); | ||
}); | ||
@@ -65,2 +68,16 @@ return this; | ||
/** | ||
* @deprecated | ||
*/ | ||
until(destroyEvent) { | ||
return this.emitUntil(destroyEvent); | ||
} | ||
/** | ||
* Completes subject and clean up resources | ||
*/ | ||
close() { | ||
this._internalPromise = null; | ||
this.complete(); | ||
this.hub.unsubscribe(); | ||
} | ||
/** | ||
* Attaches callbacks for the resolution and/or rejection of the Promise. | ||
@@ -67,0 +84,0 @@ * @param onfulfilled The callback to execute when the Promise is resolved. |
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
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
38829
649
27