UNPKG

@rxx/core

Version:

React MVI micro framework.

110 lines (109 loc) 3.6 kB
/** * The MIT License (MIT) * Copyright (c) Taketoshi Aono * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * @fileoverview * @author Taketoshi Aono */ import { Observable, Subject, Subscription } from 'rxjs'; import { StreamCollection } from './stream-collection'; import { Advice, AdviceFunction } from './advice'; import { IntentHandler } from '../intent/intent-handler'; import { SubjectTree } from '../subject'; /** * Represent StateHandler response. */ export declare class HandlerResponse { private streamCollection; constructor(streamCollection: StreamCollection); /** * Get a subject by specify key. * @param key Subject name. * @returns Registered Subject. */ for<T, V>(key: string): Observable<StateHandlerData<T, V>>; } /** * Hold Subject cache. */ export declare class StreamStore implements StreamCollection { private subjectMap; constructor(subjectMap?: { [key: string]: Subject<any>; }); /** * @inheritDoc */ hasWithoutGlobal(key: string): boolean; /** * @inheritDoc */ has(key: string): boolean; /** * @inheritDoc */ getWithoutGlobal(key: string): Subject<any>; /** * @inheritDoc */ get(keySpace: string, create?: boolean): Subject<any>[]; /** * @inheritDoc */ add<T>(key: string): Subject<T>; } /** * Interface for state handler. */ export interface Handler { response: HandlerResponse; /** * Wait observable. * @param request Disposable. */ subscribe(props: { [key: string]: any; }): Subscription; /** * Publish specified key io event. * @param key Event name. * @param args Event args. */ push(key: string, args?: any): Promise<any>; /** * Get callback function that publish specified key event. * @param key Event name. * @param v Event args that override event args. * @returns Function that publish event. */ callback<Args, ReturnType>(key: string, value?: any): (args?: Args) => Promise<ReturnType>; /** * State setter by Provisioning. */ setState(state: any): void; setSubject(subject: SubjectTree): void; setIntent(intent: IntentHandler): void; clone<T = Handler>(...args: any[]): Handler; readonly intent: IntentHandler; } export declare type Advices = { [key: string]: Advice | AdviceFunction; }; export declare type CutPoints = { [key: string]: string | string[]; }; export declare type StateHandlerData<Value, State> = { data: Value; state: State; };