StatefulMixin

Hierarchy

Implements

Index

Properties

Methods

Properties

state

state: State

Implementation of Stateful.state

Methods

getSelectableStates

getSelectableStates(): Record‹string, State

Implementation of Stateful

Returns all selectable states.

Returns: Record‹string, State

Collection of available states.


getState

getState(): State

Implementation of Stateful

Returns current state of instance.

Returns: State

Current state of instance as string.


hasState

hasState(): boolean

Implementation of Stateful

Evaluates if target has state set on instance(is not nil).

Returns: boolean

Returns true if instance has state set(not nil), else false.


isInOneOfStates

isInOneOfStates(states: State | State[]): boolean

Implementation of Stateful

Evaluates if target is in one of expected state.

Parameters:

NameTypeDescription
statesState | State[]Expected states in which one of instance should be.

Returns: boolean

Returns true if instance is in one of states, else false.


isInState

isInState(state: State | State[]): boolean

Implementation of Stateful

Evaluates if target is in expected state.

Parameters:

NameTypeDescription
stateState | State[]Expected state in which instance should be.

Returns: boolean

Returns true if instance is in state, else false.


setState

setState(state: State): void

Implementation of Stateful

Sets instance state.

throws {ValidationError} Thrown if the provided state does not match one of the selectable states.

throws {UndefinedStatesError} Thrown if the instance does not have any states assigned.

Parameters:

NameTypeDescription
stateStateState to which instance should be set.

Returns: void


validateState

validateState(stateOrStates: State | State[], error?: Error): boolean

Implementation of Stateful

Validates if instance is in allowed state(s).

throws {InvalidStateError} Thrown if target is not in correct(one of allowed) state.

Parameters:

NameTypeDescription
stateOrStatesState | State[]Expected states list in one of which instance should be.
error?ErrorOptional error instance for case where state does not match expected one.

Returns: boolean

Returns true if instance is in correct state, else throws.