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
Key | Value | Description |
---|---|---|
SET | 1 | Indicates that the change was triggered by calling `.set`. |
RESET | 2 | Indicates that the change was triggered by calling `.reset`. |
INIT | 3 | Indicates that the change was triggered by calling `.init`. |