Comparing version 0.2.8 to 0.2.9
@@ -5,3 +5,3 @@ declare const $get: unique symbol; | ||
/** Returns true if `arg` can be observed. */ | ||
declare const hasFluidValue: (arg: any) => arg is FluidValue<any, AnyEvent>; | ||
declare const hasFluidValue: (arg: any) => arg is FluidValue<any, UnknownFluidEvent<any>>; | ||
/** | ||
@@ -27,3 +27,3 @@ * Get the current value. | ||
}; | ||
/** An event sent to `FluidObserver` objects. */ | ||
/** An event from a `FluidValue` instance */ | ||
export interface FluidEvent<T = any> { | ||
@@ -33,7 +33,7 @@ type: string; | ||
} | ||
/** @internal */ | ||
export interface AnyEvent extends FluidEvent { | ||
/** An event from any `FluidValue` instance */ | ||
export interface UnknownFluidEvent<T = any> extends FluidEvent<T> { | ||
[key: string]: any; | ||
} | ||
/** @internal */ | ||
/** An untyped event from a `fluids` compatible object */ | ||
export interface UnsafeFluidEvent { | ||
@@ -45,8 +45,8 @@ type: string; | ||
/** | ||
* Extend this class for automatic TypeScript support when passing this | ||
* value to `fluids`-compatible libraries. | ||
* Extend this class for automatic TypeScript support when passing | ||
* an object to a `fluids` compatible function. | ||
*/ | ||
declare abstract class FluidValue<T = any, E extends FluidEvent<T> = AnyEvent> { | ||
private [$get]; | ||
private [$observers]?; | ||
declare abstract class FluidValue<T = any, E extends FluidEvent<T> = UnknownFluidEvent<T>> { | ||
protected [$get]: () => T; | ||
protected [$observers]?: Set<FluidObserver<E>>; | ||
constructor(get?: () => T); | ||
@@ -56,8 +56,8 @@ /** Get the current value. */ | ||
/** Called after an observer is added. */ | ||
protected observerAdded?(count: number, observer: FluidObserver<E>): void; | ||
protected observerAdded?(count: number, observer: FluidObserver): void; | ||
/** Called after an observer is removed. */ | ||
protected observerRemoved?(count: number, observer: FluidObserver<E>): void; | ||
protected observerRemoved?(count: number, observer: FluidObserver): void; | ||
} | ||
/** An observer of `FluidValue` objects. */ | ||
export declare type FluidObserver<E extends FluidEvent = AnyEvent> = { | ||
export declare type FluidObserver<E extends UnsafeFluidEvent = UnsafeFluidEvent> = { | ||
eventObserved(event: E): void; | ||
@@ -79,5 +79,5 @@ } | { | ||
declare function addFluidObserver<T, E extends FluidEvent>(target: FluidValue<T, E>, observer: FluidObserver<E>): typeof observer; | ||
declare function addFluidObserver<E extends FluidEvent>(target: object, observer: FluidObserver<E>): typeof observer; | ||
declare function addFluidObserver<E extends UnsafeFluidEvent>(target: object, observer: FluidObserver<E>): typeof observer; | ||
/** Stop observing a `fluids`-compatible object. */ | ||
declare function removeFluidObserver<E extends FluidEvent>(target: FluidValue<any, E>, observer: FluidObserver<E>): void; | ||
declare function removeFluidObserver<E extends FluidEvent>(target: object, observer: FluidObserver<E>): void; | ||
declare function removeFluidObserver<E extends UnsafeFluidEvent>(target: object, observer: FluidObserver<E>): void; |
@@ -41,4 +41,4 @@ "use strict"; | ||
/** | ||
* Extend this class for automatic TypeScript support when passing this | ||
* value to `fluids`-compatible libraries. | ||
* Extend this class for automatic TypeScript support when passing | ||
* an object to a `fluids` compatible function. | ||
*/ | ||
@@ -45,0 +45,0 @@ var FluidValue = /** @class */ (function () { |
@@ -5,3 +5,3 @@ declare const $get: unique symbol; | ||
/** Returns true if `arg` can be observed. */ | ||
declare const hasFluidValue: (arg: any) => arg is FluidValue<any, AnyEvent>; | ||
declare const hasFluidValue: (arg: any) => arg is FluidValue<any, UnknownFluidEvent<any>>; | ||
/** | ||
@@ -27,3 +27,3 @@ * Get the current value. | ||
}; | ||
/** An event sent to `FluidObserver` objects. */ | ||
/** An event from a `FluidValue` instance */ | ||
export interface FluidEvent<T = any> { | ||
@@ -33,7 +33,7 @@ type: string; | ||
} | ||
/** @internal */ | ||
export interface AnyEvent extends FluidEvent { | ||
/** An event from any `FluidValue` instance */ | ||
export interface UnknownFluidEvent<T = any> extends FluidEvent<T> { | ||
[key: string]: any; | ||
} | ||
/** @internal */ | ||
/** An untyped event from a `fluids` compatible object */ | ||
export interface UnsafeFluidEvent { | ||
@@ -45,8 +45,8 @@ type: string; | ||
/** | ||
* Extend this class for automatic TypeScript support when passing this | ||
* value to `fluids`-compatible libraries. | ||
* Extend this class for automatic TypeScript support when passing | ||
* an object to a `fluids` compatible function. | ||
*/ | ||
declare abstract class FluidValue<T = any, E extends FluidEvent<T> = AnyEvent> { | ||
private [$get]; | ||
private [$observers]?; | ||
declare abstract class FluidValue<T = any, E extends FluidEvent<T> = UnknownFluidEvent<T>> { | ||
protected [$get]: () => T; | ||
protected [$observers]?: Set<FluidObserver<E>>; | ||
constructor(get?: () => T); | ||
@@ -56,8 +56,8 @@ /** Get the current value. */ | ||
/** Called after an observer is added. */ | ||
protected observerAdded?(count: number, observer: FluidObserver<E>): void; | ||
protected observerAdded?(count: number, observer: FluidObserver): void; | ||
/** Called after an observer is removed. */ | ||
protected observerRemoved?(count: number, observer: FluidObserver<E>): void; | ||
protected observerRemoved?(count: number, observer: FluidObserver): void; | ||
} | ||
/** An observer of `FluidValue` objects. */ | ||
export declare type FluidObserver<E extends FluidEvent = AnyEvent> = { | ||
export declare type FluidObserver<E extends UnsafeFluidEvent = UnsafeFluidEvent> = { | ||
eventObserved(event: E): void; | ||
@@ -79,5 +79,5 @@ } | { | ||
declare function addFluidObserver<T, E extends FluidEvent>(target: FluidValue<T, E>, observer: FluidObserver<E>): typeof observer; | ||
declare function addFluidObserver<E extends FluidEvent>(target: object, observer: FluidObserver<E>): typeof observer; | ||
declare function addFluidObserver<E extends UnsafeFluidEvent>(target: object, observer: FluidObserver<E>): typeof observer; | ||
/** Stop observing a `fluids`-compatible object. */ | ||
declare function removeFluidObserver<E extends FluidEvent>(target: FluidValue<any, E>, observer: FluidObserver<E>): void; | ||
declare function removeFluidObserver<E extends FluidEvent>(target: object, observer: FluidObserver<E>): void; | ||
declare function removeFluidObserver<E extends UnsafeFluidEvent>(target: object, observer: FluidObserver<E>): void; |
@@ -36,4 +36,4 @@ var $get = Symbol.for('FluidValue.get'); | ||
/** | ||
* Extend this class for automatic TypeScript support when passing this | ||
* value to `fluids`-compatible libraries. | ||
* Extend this class for automatic TypeScript support when passing | ||
* an object to a `fluids` compatible function. | ||
*/ | ||
@@ -40,0 +40,0 @@ var FluidValue = /** @class */ (function () { |
{ | ||
"name": "fluids", | ||
"version": "0.2.8", | ||
"version": "0.2.9", | ||
"description": "Glue layer for reactivity", | ||
@@ -5,0 +5,0 @@ "main": "dist/cjs/index", |
@@ -81,3 +81,3 @@ const $get = Symbol.for('FluidValue.get') | ||
/** An event sent to `FluidObserver` objects. */ | ||
/** An event from a `FluidValue` instance */ | ||
export interface FluidEvent<T = any> { | ||
@@ -88,8 +88,8 @@ type: string | ||
/** @internal */ | ||
export interface AnyEvent extends FluidEvent { | ||
/** An event from any `FluidValue` instance */ | ||
export interface UnknownFluidEvent<T = any> extends FluidEvent<T> { | ||
[key: string]: any | ||
} | ||
/** @internal */ | ||
/** An untyped event from a `fluids` compatible object */ | ||
export interface UnsafeFluidEvent { | ||
@@ -102,10 +102,11 @@ type: string | ||
/** | ||
* Extend this class for automatic TypeScript support when passing this | ||
* value to `fluids`-compatible libraries. | ||
* Extend this class for automatic TypeScript support when passing | ||
* an object to a `fluids` compatible function. | ||
*/ | ||
abstract class FluidValue<T = any, E extends FluidEvent<T> = AnyEvent> { | ||
// @ts-ignore | ||
private [$get]: () => T | ||
// @ts-ignore | ||
private [$observers]?: Set<FluidObserver<E>> | ||
abstract class FluidValue< | ||
T = any, | ||
E extends FluidEvent<T> = UnknownFluidEvent<T> | ||
> { | ||
protected [$get]: () => T | ||
protected [$observers]?: Set<FluidObserver<E>> | ||
@@ -121,10 +122,12 @@ constructor(get?: () => T) { | ||
protected get?(): T | ||
/** Called after an observer is added. */ | ||
protected observerAdded?(count: number, observer: FluidObserver<E>): void | ||
protected observerAdded?(count: number, observer: FluidObserver): void | ||
/** Called after an observer is removed. */ | ||
protected observerRemoved?(count: number, observer: FluidObserver<E>): void | ||
protected observerRemoved?(count: number, observer: FluidObserver): void | ||
} | ||
/** An observer of `FluidValue` objects. */ | ||
export type FluidObserver<E extends FluidEvent = AnyEvent> = | ||
export type FluidObserver<E extends UnsafeFluidEvent = UnsafeFluidEvent> = | ||
| { eventObserved(event: E): void } | ||
@@ -153,3 +156,3 @@ | { (event: E): void } | ||
function addFluidObserver<E extends FluidEvent>( | ||
function addFluidObserver<E extends UnsafeFluidEvent>( | ||
target: object, | ||
@@ -181,3 +184,3 @@ observer: FluidObserver<E> | ||
function removeFluidObserver<E extends FluidEvent>( | ||
function removeFluidObserver<E extends UnsafeFluidEvent>( | ||
target: object, | ||
@@ -184,0 +187,0 @@ observer: FluidObserver<E> |
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
27686
512