Skip to main content

StateChangeEventType

Overview

Type: enum

The type of state change event that was triggered.


This value is provided in the .watch callback to indicate which event triggered it.

import { StateManager } from 'cotton-box'

const ExampleState = new StateManager(0)

ExampleState.set(42)

ExampleState.watch((state, eventType) => {
console.log(state) // 42
console.log(eventType) // 1 (StateChangeEventType.SET)
})

Values

KeyValueDescription
SET1Indicates that the change was triggered by calling `.set`.
RESET2Indicates that the change was triggered by calling `.reset`.
INIT3Indicates that the change was triggered by calling `.init`.