MiniState is the core class of the mini-state library, providing a simple, signal-based state management solution for Angular applications. It handles async operations, loading states, errors, and success messages with a clean, declarative API.
Note: The recommended way to initialize a MiniState is through the MiniStateBuilder. It simplifies the setup and ensures best practices are followed.
Creates a new MiniState instance with the specified trigger function and optional parameters.
MiniState provides both signals and observables for all state properties:
Methods to initiate or repeat operations:
Methods to customize MiniState behavior:
Methods to directly modify the data state:
Methods for error management:
Sets a function to generate custom success messages after successful operations.
Sets a function to convert error objects to user-friendly error messages.
Sets a function to process and transform the raw output data before it's stored and emitted.
Sets a function to be called after a successful operation completes.
Sets a function to be called when an operation fails.
Sets a function to be called when a trigger is initiated, before the async operation begins.
The following example demonstrates a complete user search component using MiniState:
Just using if statements rather tha input triggered popups to demonstrate the functionality clearer