Class ExpressionManager<Expression, ExpressionSpec>Abstract

Abstract expression manager.

Emits

ExpressionManagerEvents

Type Parameters

  • Expression = any

  • ExpressionSpec = any

Hierarchy

Constructors

Properties

currentExpression: Expression

Current Expression. This will not be overwritten by defaultExpression.

defaultExpression: Expression

An empty Expression to reset all the expression parameters.

definitions: ExpressionSpec[]

Expression definitions copied from ModelSettings.

destroyed: boolean = false

Flags the instance has been destroyed.

expressions: (undefined | null | Expression)[] = []

The Expressions. The structure is the same as definitions, initially there's only an empty array, which means all expressions will be undefined. When an Expression has been loaded, it'll fill the place in which it should be; when it fails to load, the place will be filled with null.

reserveExpressionIndex: number = -1

The pending Expression.

settings: ModelSettings

The ModelSettings reference.

tag: string

Tag for logging.

prefixed: string | boolean

Methods

  • Creates an Expression from the data.

    Returns

    The created Expression.

    Parameters

    • data: object

      Content of the expression file.

    • definition: undefined | ExpressionSpec

      The expression definition. Can be undefined in order to create defaultExpression.

    Returns Expression

  • Calls each of the listeners registered for a given event.

    Parameters

    Returns boolean

  • Return an array listing the events for which the emitter has registered listeners.

    Returns (keyof ExpressionManagerEvents<any>)[]

  • Retrieves the expression's file path by its definition.

    Returns

    The file path extracted from given definition. Not resolved.

    Parameters

    • definition: ExpressionSpec

    Returns string

  • Retrieves the expression's index by its name.

    Returns

    The index. -1 if not found.

    Parameters

    • name: string

    Returns number

  • Return the number of listeners listening to a given event.

    Parameters

    Returns number

  • Return the listeners registered for a given event.

    Parameters

    Returns ListenerFn[]

  • Loads an Expression. Errors in this method will not be thrown, but be emitted with an "expressionLoadError" event.

    Returns

    Promise that resolves with the Expression, or with undefined if it can't be loaded.

    Emits

    expressionLoaded

    Emits

    expressionLoadError

    Parameters

    • index: number

      Index of the expression in definitions.

    Returns Promise<undefined | Expression>

  • Parameters

    Returns ExpressionManager<Expression, ExpressionSpec>

  • Remove the listeners of a given event.

    Parameters

    Returns ExpressionManager<Expression, ExpressionSpec>

  • Sets an Expression.

    Returns

    Promise that resolves with true if succeeded, with false otherwise.

    Parameters

    • index: string | number

      Either the index, or the name of the expression.

    Returns Promise<boolean>

  • Sets a random Expression that differs from current one.

    Returns

    Promise that resolves with true if succeeded, with false otherwise.

    Returns Promise<boolean>

  • Updates parameters of the core model.

    Returns

    True if the parameters are actually updated.

    Parameters

    • model: object
    • now: number

    Returns boolean

  • Updates parameters of the core model.

    Returns

    True if the parameters are actually updated.

    Parameters

    • model: object
    • now: number

    Returns boolean

Generated using TypeDoc