vasille
Version:
The same framework which is designed to build bulletproof frontends (core library).
41 lines (40 loc) • 1.16 kB
TypeScript
import { Reactive } from "../core/core.js";
import { Destroyable } from "../core/destroyable.js";
import { IValue } from "../core/ivalue.js";
export type KindOfIValue<T extends unknown[]> = {
[K in keyof T]: IValue<T[K]> | undefined;
};
/**
* Bind some values to one expression
* @class Expression
* @extends IValue
*/
export declare class Expression<T, Args extends unknown[]> extends IValue<T> implements Destroyable {
/**
* The array of value which will trigger recalculation
* @type {Array}
*/
private values;
/**
* Cache the values of expression variables
* @type {Array}
*/
private readonly valuesCache;
/**
* Expression will link different handler for each value of the list
*/
private linkedFunc;
/**
* The buffer to keep the last calculated value
*/
private sync;
/**
* Creates a function bounded to N values
*/
constructor(func: (...args: Args) => T, values: KindOfIValue<Args>, ctx?: Reactive);
get V(): T;
set V(value: T);
on(handler: (value: T) => void): void;
off(handler: (value: T) => void): void;
destroy(): void;
}