micro-observables
Advanced tools
Comparing version 2.0.0-alpha3 to 2.0.0-alpha4
@@ -16,3 +16,3 @@ export declare type Listener<T> = (val: T, prevVal: T) => void; | ||
protected _outputs: Observable<any>[]; | ||
_revision: Revision; | ||
protected _revision: Revision; | ||
protected _refreshRevision: Revision; | ||
@@ -24,3 +24,3 @@ protected _attached: boolean; | ||
static onGet: ((observable: Observable<any>) => void) | undefined; | ||
refresh(): boolean; | ||
protected refresh(): boolean; | ||
protected abstract evaluate(): T; | ||
@@ -42,8 +42,2 @@ subscribe(listener: Listener<T>): Unsubscriber; | ||
} | ||
export declare class DefaultValObservable<T> extends Observable<T> { | ||
protected _defaultVal: T; | ||
constructor(defaultVal: T, options?: Options<T>); | ||
get defaultVal(): T; | ||
protected evaluate(): T; | ||
} | ||
export declare class WritableObservable<T> extends Observable<T> { | ||
@@ -50,0 +44,0 @@ private _defaultVal; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DerivedObservable = exports.WritableObservable = exports.DefaultValObservable = exports.Observable = exports.UNSET = void 0; | ||
exports.DerivedObservable = exports.WritableObservable = exports.Observable = exports.UNSET = void 0; | ||
const batchedUpdate_1 = require("./batchedUpdate"); | ||
@@ -15,3 +15,3 @@ exports.UNSET = Symbol(); | ||
this._outputs = []; | ||
/*protected */ this._revision = -1; | ||
this._revision = -1; | ||
this._refreshRevision = -1; | ||
@@ -28,3 +28,3 @@ this._attached = false; | ||
} | ||
/*protected */ refresh() { | ||
refresh() { | ||
if (this._refreshRevision === globalRevision) { | ||
@@ -163,15 +163,2 @@ return false; | ||
exports.Observable = Observable; | ||
class DefaultValObservable extends Observable { | ||
constructor(defaultVal, options) { | ||
super(options); | ||
this._defaultVal = defaultVal; | ||
} | ||
get defaultVal() { | ||
return this._defaultVal; | ||
} | ||
evaluate() { | ||
return this._defaultVal; | ||
} | ||
} | ||
exports.DefaultValObservable = DefaultValObservable; | ||
class WritableObservable extends Observable { | ||
@@ -229,2 +216,7 @@ constructor(defaultVal, options) { | ||
} | ||
// Note: we are lying to Typescript here: inputs should actually be a Map<Observable<any>, Revision> | ||
// as inputs can be WritableObservables or any other types of observables. But the "protected" access-modifier | ||
// behaves differently in Typescript than in other OOP languagues and we wouldn't be able to access refresh() | ||
// or _revision otherwise. An alternative could be to declare refresh() as public and to annotate it with an | ||
// "internal" comment-hint but I find it less elegant | ||
const inputs = new Map(); | ||
@@ -231,0 +223,0 @@ const prevOnGet = Observable.onGet; |
{ | ||
"name": "micro-observables", | ||
"version": "2.0.0-alpha3", | ||
"version": "2.0.0-alpha4", | ||
"description": "A simple Observable library that can be used for easy state management in React applications.", | ||
@@ -5,0 +5,0 @@ "author": "BeTomorrow", |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
59059
580