export interface Handlers { dispose: DisposeEventHandler[]; get: GetEventHandler[]; reset: ResetEventHandler[]; set: SetEventHandler[]; } export declare type SetEventHandler = (key: keyof StoreType, newValue: any, oldValue: any) => void; export declare type GetEventHandler = (key: keyof StoreType) => void; export declare type ResetEventHandler = () => void; export declare type DisposeEventHandler = () => void; export interface OnHandler { (eventName: 'set', callback: SetEventHandler): () => void; (eventName: 'get', callback: GetEventHandler): () => void; (eventName: 'dispose', callback: DisposeEventHandler): () => void; (eventName: 'reset', callback: ResetEventHandler): () => void; } export interface OnChangeHandler { (propName: Key, cb: (newValue: StoreType[Key]) => void): () => void; } export interface Subscription { dispose?(): void; get?(key: KeyFromStoreType): void; set?(key: KeyFromStoreType, newValue: StoreType[KeyFromStoreType], oldValue: StoreType[KeyFromStoreType]): void; reset?(): void; } export interface Getter {

(propName: P & string): T[P]; } export interface Setter {

(propName: P & string, value: T[P]): void; } export interface ObservableMap { /** * Proxied object that will detect dependencies and call * the subscriptions and computed properties. * * If available, it will detect from which Stencil Component * it was called and rerender it when the property changes. * * Note: Proxy objects are not supported by IE11 (not even with a polyfill) * so you need to use the store.get and store.set methods of the API if you wish to support IE11. * */ state: T; /** * Only useful if you need to support IE11. * * @example * const { state, get } = createStore({ hola: 'hello', adios: 'goodbye' }); * console.log(state.hola); // If you don't need to support IE11, use this way. * console.log(get('hola')); // If you need to support IE11, use this other way. */ get: Getter; /** * Only useful if you need to support IE11. * * @example * const { state, get } = createStore({ hola: 'hello', adios: 'goodbye' }); * state.hola = 'ola'; // If you don't need to support IE11, use this way. * set('hola', 'ola')); // If you need to support IE11, use this other way. */ set: Setter; /** * Register a event listener, you can listen to `set`, `get` and `reset` events. * * @example * store.on('set', (prop, value) => { * console.log(`Prop ${prop} changed to: ${value}`); * }); */ on: OnHandler; /** * Easily listen for value changes of the specified key. */ onChange: OnChangeHandler; /** * Resets the state to its original state and * signals a dispose event to all the plugins. * * This method is intended for plugins to reset * all their internal state between tests. */ dispose(): void; /** * Resets the state to its original state. */ reset(): void; /** * Registers a subscription that will be called whenever the user gets, sets, or * resets a value. */ use(...plugins: Subscription[]): () => void; /** * Force a rerender of the specified key, just like the value changed. */ forceUpdate(key: keyof T): any; }