The StateSchema that the class will follow
interface StateSchema {
myString: string | null;
favoriteNumber: number;
}
const defaultState: StateSchema = {
myString: null,
favoriteNumber: 3,
};
export const state: State<StateSchema> = new State(defaultState);
Private
_valuesconsole.log(state.values.favoriteNumber); // 3
Set the values in state to be accessed anywhere
The partial values of StateSchema to change
const favoriteNumber: number = 5;
state.setValues({ favoriteNumber });
The state class takes in a StateSchema defined as whatever you want it to be. It allows for access anywhere from the program.