import { Store, StoreEnhancer } from 'redux'; // // Decorators // /** * Method decorator. * * Mark this method as a Redux action. */ export function action(target: object, propertyKey: string | symbol): void; /** * Class decorator. * * Mark this class as a redux component. */ export function component(ctor: Function): any; /** * Method decorator. * * The method will dispatch an action with the corresponding name but the * dispatched action will **not** trigger a reducer reaction. Instead, after the * dispatch process is done the method will be invoked as a regular one * (similarly to `noDispatch` methods). */ export function sequence(target: any, propertyKey: string | symbol): void; /** * Property decorator. */ export function withId(target: object, propertyKey: string | symbol): void; export function withId(id?: any): PropertyDecorator; /** * Property decorator. * Instruct redux-app to not store this property in the store. */ export function ignoreState(target: object, propertyKey: string | symbol): void; // // ReduxApp // export class ReduxApp { /** * Global redux-app options. */ static options: GlobalOptions; static createApp(appCreator: T, enhancer?: StoreEnhancer): ReduxApp; static createApp(appCreator: T, options: AppOptions, enhancer?: StoreEnhancer): ReduxApp; static createApp(appCreator: T, options: AppOptions, preloadedState: any, enhancer?: StoreEnhancer): ReduxApp; /** * @param type The type of the component. * @param componentId The ID of the component (assuming the ID was assigned * to the component by the 'withId' decorator). If not specified will get to * the first available component of that type. * @param appId The name of the ReduxApp instance to search in. If not * specified will search in default app. */ static getComponent(type: Constructor, componentId?: string, appId?: string): T; readonly name: string; /** * The root component of the application. */ readonly root: T; /** * The underlying redux store. */ readonly store: Store; constructor(appCreator: T, enhancer?: StoreEnhancer); constructor(appCreator: T, options: AppOptions, enhancer?: StoreEnhancer); constructor(appCreator: T, options: AppOptions, preloadedState: any, enhancer?: StoreEnhancer); dispose(): void; } // // Utilities // export function isInstanceOf(obj: any, type: Function): boolean; /** * @param obj * @param bind Whether or not to bind the returned methods to 'obj'. Default * value: false. */ export function getMethods(obj: object | Function, bind?: boolean): IMap; // // types // export type Method = Function; export interface Constructor { new(...args: any[]): T; } export interface IMap { [key: string]: T; } // // Options // export class ActionOptions { /** * Add the class name of the object that holds the action to the action name. * Format: * Default value: true. */ actionNamespace?: boolean; /** * Default value: . (dot) */ actionNamespaceSeparator?: string; /** * Use redux style action names. For instance, if a component defines a * method called 'incrementCounter' the matching action name will be * 'INCREMENT_COUNTER'. * Default value: false. */ uppercaseActions?: boolean; } export class AppOptions { /** * Name of the newly created app. */ name?: string; /** * By default each component is assigned (with some optimizations) with it's * relevant sub state on each store change. Set this to false to disable * this updating process. The store's state will still be updated as usual * and can always be retrieved using store.getState(). * Default value: true. */ updateState?: boolean; } export class GlobalOptions { /** * Default value: LogLevel.Warn */ logLevel: LogLevel; /** * Customize actions naming. */ action: ActionOptions; } export enum LogLevel { /** * Emit no logs */ None = 0, Verbose = 1, Debug = 2, Warn = 5, /** * Emit no logs (same as None) */ Silent = 10 }