@proscom/prostore
Advanced tools
Comparing version 0.2.8 to 0.2.10
@@ -6,5 +6,4 @@ "use strict"; | ||
var rxjs_1 = require("rxjs"); | ||
var operators_1 = require("rxjs/operators"); | ||
var onSubscription_1 = require("./onSubscription"); | ||
var proxyToBehaviorSubject_1 = require("./proxyToBehaviorSubject"); | ||
var onFirstSubscription_1 = require("./onFirstSubscription"); | ||
/** | ||
@@ -22,3 +21,3 @@ * Prostore which uses BehaviorSubject to hold its state. | ||
var subject$ = new rxjs_1.BehaviorSubject(initialState); | ||
this.state$ = proxyToBehaviorSubject_1.proxyToBehaviorSubject(subject$.pipe(onSubscription_1.onSubscription(function () { return _this.onSubscribe(); }, function () { return _this.onUnsubscribe(); }), operators_1.share()), subject$); | ||
this.state$ = proxyToBehaviorSubject_1.proxyToBehaviorSubject(subject$.pipe(onFirstSubscription_1.onFirstSubscription(function () { return _this.onSubscribe(); }, function () { return _this.onUnsubscribe(); })), subject$); | ||
} | ||
@@ -25,0 +24,0 @@ Object.defineProperty(BehaviorStore.prototype, "state", { |
import { __assign } from "tslib"; | ||
import { BehaviorSubject } from 'rxjs'; | ||
import { share } from 'rxjs/operators'; | ||
import { onSubscription } from './onSubscription'; | ||
import { proxyToBehaviorSubject } from "./proxyToBehaviorSubject"; | ||
import { onFirstSubscription } from "./onFirstSubscription"; | ||
/** | ||
@@ -18,3 +17,3 @@ * Prostore which uses BehaviorSubject to hold its state. | ||
var subject$ = new BehaviorSubject(initialState); | ||
this.state$ = proxyToBehaviorSubject(subject$.pipe(onSubscription(function () { return _this.onSubscribe(); }, function () { return _this.onUnsubscribe(); }), share()), subject$); | ||
this.state$ = proxyToBehaviorSubject(subject$.pipe(onFirstSubscription(function () { return _this.onSubscribe(); }, function () { return _this.onUnsubscribe(); })), subject$); | ||
} | ||
@@ -21,0 +20,0 @@ Object.defineProperty(BehaviorStore.prototype, "state", { |
export * from './AsyncBehaviorStore'; | ||
export * from './BehaviorStore'; | ||
export * from './combineLatestWith'; | ||
export * from './IMapData'; | ||
@@ -4,0 +5,0 @@ export * from './insertPaginatedSlice'; |
export * from './AsyncBehaviorStore'; | ||
export * from './BehaviorStore'; | ||
export * from './combineLatestWith'; | ||
export * from './IMapData'; | ||
@@ -4,0 +5,0 @@ export * from './insertPaginatedSlice'; |
@@ -1,7 +0,9 @@ | ||
import { Subscribable, Unsubscribable } from 'rxjs'; | ||
import { PartialObserver, Subscribable, Unsubscribable } from "rxjs"; | ||
export declare type Subscriber<T> = ((value: T) => void) | PartialObserver<T>; | ||
export declare class SubscriptionManager { | ||
subscriptions: Unsubscribable[]; | ||
subscribe: <T>(obs$: Subscribable<T>, callback?: import("rxjs").NextObserver<T> | import("rxjs").ErrorObserver<T> | import("rxjs").CompletionObserver<T> | ((value: T) => void) | undefined) => Unsubscribable; | ||
subscribeAsync: <T>(obs$: Subscribable<T>, callback?: import("rxjs").NextObserver<T> | import("rxjs").ErrorObserver<T> | import("rxjs").CompletionObserver<T> | ((value: T) => void) | undefined) => Unsubscribable; | ||
unsubscribe(sub: Unsubscribable): void; | ||
destroy(): void; | ||
} |
@@ -0,1 +1,3 @@ | ||
import { from, isObservable } from "rxjs"; | ||
import { auditTime } from 'rxjs/operators'; | ||
var SubscriptionManager = /** @class */ (function () { | ||
@@ -14,2 +16,6 @@ function SubscriptionManager() { | ||
}; | ||
this.subscribeAsync = function (obs$, callback) { | ||
var oobs$ = isObservable(obs$) ? obs$ : from(obs$); | ||
return _this.subscribe(oobs$.pipe(auditTime(0)), callback); | ||
}; | ||
} | ||
@@ -16,0 +22,0 @@ SubscriptionManager.prototype.unsubscribe = function (sub) { |
export * from './AsyncBehaviorStore'; | ||
export * from './BehaviorStore'; | ||
export * from './combineLatestWith'; | ||
export * from './IMapData'; | ||
@@ -4,0 +5,0 @@ export * from './insertPaginatedSlice'; |
@@ -6,2 +6,3 @@ "use strict"; | ||
tslib_1.__exportStar(require("./BehaviorStore"), exports); | ||
tslib_1.__exportStar(require("./combineLatestWith"), exports); | ||
tslib_1.__exportStar(require("./IMapData"), exports); | ||
@@ -8,0 +9,0 @@ tslib_1.__exportStar(require("./insertPaginatedSlice"), exports); |
@@ -1,7 +0,9 @@ | ||
import { Subscribable, Unsubscribable } from 'rxjs'; | ||
import { PartialObserver, Subscribable, Unsubscribable } from "rxjs"; | ||
export declare type Subscriber<T> = ((value: T) => void) | PartialObserver<T>; | ||
export declare class SubscriptionManager { | ||
subscriptions: Unsubscribable[]; | ||
subscribe: <T>(obs$: Subscribable<T>, callback?: import("rxjs").NextObserver<T> | import("rxjs").ErrorObserver<T> | import("rxjs").CompletionObserver<T> | ((value: T) => void) | undefined) => Unsubscribable; | ||
subscribeAsync: <T>(obs$: Subscribable<T>, callback?: import("rxjs").NextObserver<T> | import("rxjs").ErrorObserver<T> | import("rxjs").CompletionObserver<T> | ((value: T) => void) | undefined) => Unsubscribable; | ||
unsubscribe(sub: Unsubscribable): void; | ||
destroy(): void; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SubscriptionManager = void 0; | ||
var rxjs_1 = require("rxjs"); | ||
var operators_1 = require("rxjs/operators"); | ||
var SubscriptionManager = /** @class */ (function () { | ||
@@ -17,2 +19,6 @@ function SubscriptionManager() { | ||
}; | ||
this.subscribeAsync = function (obs$, callback) { | ||
var oobs$ = rxjs_1.isObservable(obs$) ? obs$ : rxjs_1.from(obs$); | ||
return _this.subscribe(oobs$.pipe(operators_1.auditTime(0)), callback); | ||
}; | ||
} | ||
@@ -19,0 +25,0 @@ SubscriptionManager.prototype.unsubscribe = function (sub) { |
{ | ||
"name": "@proscom/prostore", | ||
"version": "0.2.8", | ||
"version": "0.2.10", | ||
"description": "State management library with multiple stores based on rxjs", | ||
@@ -42,3 +42,3 @@ "author": "Andrew Starostin <a.starostin@proscom.ru>", | ||
}, | ||
"gitHead": "1ade3227d4f5ecdbdc799a28382bf538328ac5f4" | ||
"gitHead": "e00165a18de9b35cd6c8f3528d34cc779943904a" | ||
} |
@@ -6,2 +6,3 @@ import { BehaviorSubject } from 'rxjs'; | ||
import { proxyToBehaviorSubject } from "./proxyToBehaviorSubject"; | ||
import { onFirstSubscription } from "./onFirstSubscription"; | ||
@@ -34,4 +35,3 @@ export type IStateUpdaterFunc<State extends object> = ( | ||
subject$.pipe( | ||
onSubscription(() => this.onSubscribe(), () => this.onUnsubscribe()), | ||
share() | ||
onFirstSubscription(() => this.onSubscribe(), () => this.onUnsubscribe()) | ||
), | ||
@@ -38,0 +38,0 @@ subject$ |
@@ -0,0 +0,0 @@ import { Observable, Subscribable } from 'rxjs'; |
export * from './AsyncBehaviorStore'; | ||
export * from './BehaviorStore'; | ||
export * from './combineLatestWith'; | ||
export * from './IMapData'; | ||
@@ -4,0 +5,0 @@ export * from './insertPaginatedSlice'; |
@@ -1,10 +0,10 @@ | ||
import { Subscribable, Unsubscribable, PartialObserver } from 'rxjs'; | ||
import { from, isObservable, PartialObserver, Subscribable, Unsubscribable } from "rxjs"; | ||
import { auditTime } from 'rxjs/operators'; | ||
export type Subscriber<T> = ((value: T) => void) | PartialObserver<T>; | ||
export class SubscriptionManager { | ||
subscriptions: Unsubscribable[] = []; | ||
subscribe = <T>( | ||
obs$: Subscribable<T>, | ||
callback?: ((value: T) => void) | PartialObserver<T> | ||
) => { | ||
subscribe = <T>(obs$: Subscribable<T>, callback?: Subscriber<T>) => { | ||
const sub = | ||
@@ -19,2 +19,7 @@ // Get around calling ts function overload with union argument | ||
subscribeAsync = <T>(obs$: Subscribable<T>, callback?: Subscriber<T>) => { | ||
const oobs$ = isObservable(obs$) ? obs$ : from(obs$); | ||
return this.subscribe(oobs$.pipe(auditTime(0)), callback); | ||
}; | ||
unsubscribe(sub: Unsubscribable) { | ||
@@ -21,0 +26,0 @@ sub.unsubscribe(); |
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
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
162557
121
2726