State

Definition

function State(initial: any) {
    return {
        update: function,
        get: function,
        onUpdate: function
    }
}

Input

Takes initial of any type

Returns an object

  • update(value: any) : updates the current state with the input value

  • get() : returns the current state

  • onUpdate(value: function) : takes a callback function and calls the function whenever the state is updated

Last updated