|
|
import { DeclareConstructor } from "./_base/declare";
|
|
|
import { Handle, WatchHandle } from "./interfaces";
|
|
|
|
|
|
interface Stateful {
|
|
|
/**
|
|
|
* Used across all instances a hash to cache attribute names and their getter
|
|
|
* and setter names.
|
|
|
*/
|
|
|
_attrPairNames: { [attr: string]: string };
|
|
|
|
|
|
/**
|
|
|
* Helper function for get() and set().
|
|
|
* Caches attribute name values so we don't do the string ops every time.
|
|
|
*/
|
|
|
_getAttrNames(name: string): string;
|
|
|
|
|
|
/**
|
|
|
* Automatic setting of params during construction
|
|
|
*/
|
|
|
postscript(params?: Object): void;
|
|
|
|
|
|
/**
|
|
|
* Get a property on a Stateful instance.
|
|
|
*/
|
|
|
get(name: string): any;
|
|
|
|
|
|
/**
|
|
|
* Set a property on a Stateful instance
|
|
|
*/
|
|
|
set(name: string, value: any): this;
|
|
|
set(name: Object): this;
|
|
|
|
|
|
/**
|
|
|
* Internal helper for directly changing an attribute value.
|
|
|
*/
|
|
|
_changeAttrValue(name: string, value: any): this;
|
|
|
|
|
|
/**
|
|
|
* Watches a property for changes
|
|
|
*/
|
|
|
watch(callback: (prop: string, oldValue: any, newValue: any) => void): WatchHandle;
|
|
|
watch(name: string, callback: (prop: string, oldValue: any, newValue: any) => void): WatchHandle;
|
|
|
}
|
|
|
|
|
|
interface StatefulConstructor extends DeclareConstructor<Stateful> {
|
|
|
new (params?: Object): Stateful;
|
|
|
}
|
|
|
|
|
|
declare const Stateful: StatefulConstructor;
|
|
|
export = Stateful;
|
|
|
|