@rxx/core
Version:
React MVI micro framework.
74 lines (73 loc) • 2.06 kB
TypeScript
/**
* @fileoverview
* @author Taketoshi Aono
*/
import { Subscription } from 'rxjs';
import { Handler, StreamStore, HandlerResponse, CutPoints, Advices } from './handler';
import { IntentHandler } from '../intent/intent-handler';
import { SubjectTree } from '../subject';
/**
* Typedef for State handler map.
*/
export declare type StateHandlerMap = {
[key: string]: Handler;
};
/**
* Get registered stateHandlerRegistry.
*/
export declare function getHandlers(): StateHandlerMap;
/**
* Register StateHandler to handler map.
* @param newHandlers Handler map.
*/
export declare function registerHandlers(newHandlers: StateHandlerMap): {
[key: string]: HandlerResponse;
};
/**
* Remove specified handler from registry.
* @param key Key or keys of target handler.
*/
export declare function removeHandler(key: string | string[]): void;
export declare abstract class StateHandler implements Handler {
/**
* Subject for exported stream.
*/
protected readonly store: StreamStore;
/**
* Response of streams.
*/
private readonly handlerResponse;
private intentHandler;
protected state: any;
protected subject: SubjectTree;
protected advices: Advices;
protected cutPoints: CutPoints;
setState(state: any): void;
setIntent(intent: IntentHandler): void;
setSubject(subject: SubjectTree): void;
readonly intent: IntentHandler;
constructor(advices?: Advices, cutPoints?: CutPoints);
/**
* @inheritDocs
*/
abstract subscribe(props: {
[key: string]: any;
}): Subscription;
/**
* @inheritDocs
*/
abstract clone<T = Handler>(...args: any[]): Handler;
/**
* Return response representation of stream.
* @return Representation of stream response.
*/
readonly response: HandlerResponse;
/**
* @inheritDocs
*/
abstract push(key: string, args?: any): any;
/**
* @inheritDocs
*/
callback<Args = any, ReturnType = any>(key: string, value?: any): (args?: Args) => Promise<ReturnType>;
}