Type-safe state management with full IDE support
interface User {
id: number;
name: string;
email: string;
}
// State with explicit type
const user = new VnlState<User>({
id: 1,
name: 'John',
email: 'john@example.com'
});
// IDE will provide autocomplete and type checking
user.set('name', 'Jane'); // OK
user.set('age', 25); // Error: 'age' does not exist on type 'User'
Demonstrating complex state with interfaces and arrays.
Vanilla State provides options to control notifications when updating state:
state.set(value, { notify: false })state.set('propertyName', value, { notify: false })Disabling notifications updates the state without calling listeners, which can optimize performance.