UNPKG

@robotlegsjs/core

Version:

An architecture-based IoC framework for JavaScript/TypeScript

74 lines (73 loc) 2.09 kB
import { Lifecycle } from "./Lifecycle"; /** * Handles a lifecycle transition * * @private */ export declare class LifecycleTransition { private _fromStates; private _dispatcher; private _callbacks; private _name; private _lifecycle; private _transitionState; private _finalState; private _preTransitionEvent; private _transitionEvent; private _postTransitionEvent; private _reverse; /** * Creates a lifecycle transition * * @param name The name of the transition * @param lifecycle The associated lifecycle instance */ constructor(name: string, lifecycle: Lifecycle); /** * States that this transition is allowed to enter from * * @param states Allowed states * @return Self */ fromStates(...states: any[]): LifecycleTransition; /** * The states that this transition applies * * @param transitionState The state that the target is put into during the transition * @param finalState The state that the target is put into after the transition * @return */ toStates(transitionState: string, finalState: string): LifecycleTransition; /** * The events that the lifecycle will dispatch * * @param preTransitionEvent * @param transitionEvent * @param postTransitionEvent * @return Self */ withEvents(preTransitionEvent: string, transitionEvent: string, postTransitionEvent: string): LifecycleTransition; /** * Reverse the dispatch order of this transition * * @return Self */ inReverse(): LifecycleTransition; /** * A handler to run before the transition runs * * @param handler Possibly asynchronous before handler * @return Self */ addBeforeHandler(handler: Function): LifecycleTransition; /** * Attempts to enter the transition * * @param callback Completion callback */ enter(callback?: Function): void; private _invalidTransition; private _setState; private _dispatch; private _reportError; }