import Session from "./Session" ; import Transition , { Message } from "./Transition" ; export interface StateInvocationParams < T > { session : Session < T > ; transition : Transition ; msg : Message ; guarded ? : boolean ; } export default class SessionStateHelper { static Invoke < T > ( method , st ) { const target = st . session . state ; if ( typeof target !== 'undefined' && typeof method !== 'undefined' && typeof target [ method ] !== 'undefined' && typeof ( target [ method ] ) === 'function' ) { return target [ method ] ( st ) ; } return true ; } static EnterState < T > ( session , st , cst ) { SessionStateHelper . Invoke ( st + "_enter" , cst ) ; } static ExitState < T > ( session , st , cst ) { SessionStateHelper . Invoke ( st + "_exit" , cst ) ; } static Transition < T > ( session , event , cst ) { SessionStateHelper . Invoke ( event + "_transition" , cst ) ; } static CheckGuard < T > ( session , event , cst ) { return SessionStateHelper . Invoke ( event + "_guard" , cst ) ; } }