Class State<StateSchema>

The state class takes in a StateSchema defined as whatever you want it to be. It allows for access anywhere from the program.

Type Parameters

  • StateSchema

Constructors

Properties

Accessors

Methods

Constructors

  • Type Parameters

    • StateSchema

    Parameters

    • initialState: StateSchema

      The StateSchema that the class will follow

    Returns State<StateSchema>

    Example

     interface StateSchema {
    myString: string | null;
    favoriteNumber: number;
    }

    const defaultState: StateSchema = {
    myString: null,
    favoriteNumber: 3,
    };

    export const state: State<StateSchema> = new State(defaultState);

Properties

_values: StateSchema

Accessors

Methods

  • Set the values in state to be accessed anywhere

    Parameters

    Returns void

    Example

    const favoriteNumber: number = 5;
    state.setValues({ favoriteNumber });