Coordinate global application state and cross-context events. The State singleton acts as the central hub for data sharing, logic discovery, and observability.
Deletes a state property using dot-notation or bracket-notation path access.
Parameters:
path(string) - The path of the state property to delete (e.g., "user.profile.email" or "users[0].email")
Throws: Error if path is empty or invalid
Example (Node.js):
import { State } from 'micro-flow';
// Set some data
State.set('user.profile.email', 'user@example.com');
// Delete it
State.delete('user.profile.email');Iterates over a collection (array or object) located at the specified state path.
Parameters:
path(string) - The path of the state property to iterate over.callback(Function) - The function to execute for each item. Receives(item, index/key).
Retrieves a value from the state. Supports dot and bracket notation.
Parameters:
path(string) - The path to get. Use"*"or an empty string for the entire state.defaultValue(any, optional) - Value to return if path is not found (default:null).type(string, optional) - Type to cast the result to (string,number,boolean).
Sets a value in the state. Automatically creates intermediate objects or arrays if they do not exist.
Parameters:
path(string) - The path to set.value(any) - The value to store.
Example:
State.set('config.api.baseUrl', 'https://api.example.com');
State.set('users[0].name', 'Alice');Merges an object into the current State.
Resets the state to its initial default configuration.
Freezes the state object, making it immutable.