impair
Version:
impair is a React framework bringing several programming concepts together in order to provide a foundation for a layered, scalable, performant and enterprise level react application.
31 lines (30 loc) • 1.07 kB
TypeScript
import { Dictionary, Dispose } from '../types';
/**
* This decorator is used to mark a method as a trigger. It will automatically
* create a reactive effect that will call the method when the reactive dependencies change.
* The method can also accept an optional Cleanup function as a parameter.
*```ts
* @trigger
* public fetchData(cleanup: Cleanup) {
* const abortController = new AbortController()
* cleanup(() => {
* abortController.abort()
* })
*
* const response = await loadData(this.state.id, abortController.signal);
* // do something
* }
*```
*/
export declare function trigger(target: any, propertyKey: string): any;
export declare namespace trigger {
var async: (target: any, propertyKey: string) => any;
var debounce: (ms: number) => (target: any, propertyKey: string) => any;
var throttle: (ms: number) => (target: any, propertyKey: string) => any;
}
type InitParams = {
instance: Dictionary;
disposers: Dispose[];
};
export declare function initTrigger({ instance, disposers }: InitParams): void;
export {};