UNPKG

@player-ui/player

Version:

50 lines 2.59 kB
import { SyncBailHook, SyncHook, SyncWaterfallHook } from "tapable-ts"; import type { NavigationFlow, NavigationFlowState, NavigationFlowEndState } from "@player-ui/types"; import type { Logger } from "../../logger"; export interface NamedState { /** The name of the navigation node */ name: string; /** The nav node */ value: NavigationFlowState; } export interface TransitionOptions { /** Ignore any validations or other signals preventing the transition from taking place */ force?: boolean; } export type TransitionFunction = (name: string, options?: TransitionOptions) => void; /** The Content navigation state machine */ export declare class FlowInstance { private flow; private log?; private history; private isTransitioning; private flowPromise?; readonly id: string; currentState?: NamedState; readonly hooks: { beforeStart: SyncBailHook<[NavigationFlow], NavigationFlow, Record<string, any>>; /** A callback when the onStart node was present */ onStart: SyncHook<[any], Record<string, any>>; /** A callback when the onEnd node was present */ onEnd: SyncHook<[any], Record<string, any>>; /** A hook to intercept and block a transition */ skipTransition: SyncBailHook<[NamedState | undefined], boolean | undefined, Record<string, any>>; /** A chance to manipulate the flow-node used to calculate the given transition used */ beforeTransition: SyncWaterfallHook<[import("@player-ui/types").NavigationFlowViewState | import("@player-ui/types").NavigationFlowFlowState | import("@player-ui/types").NavigationFlowActionState | import("@player-ui/types").NavigationFlowExternalState, string], Record<string, any>>; /** A chance to manipulate the flow-node calculated after a transition */ resolveTransitionNode: SyncWaterfallHook<[NavigationFlowState], Record<string, any>>; /** A callback when a transition from 1 state to another was made */ transition: SyncHook<[NamedState | undefined, NamedState], Record<string, any>>; /** A callback to run actions after a transition occurs */ afterTransition: SyncHook<[FlowInstance], Record<string, any>>; }; constructor(id: string, flow: NavigationFlow, options?: { /** Logger instance to use */ logger?: Logger; }); /** Start the state machine */ start(): Promise<NavigationFlowEndState>; transition(transitionValue: string, options?: TransitionOptions): void; private pushHistory; } //# sourceMappingURL=flow.d.ts.map