API

MiniStateCombined API Documentation

MiniStateCombined is a utility class that enables aggregating multiple MiniState instances, giving you a unified way to track and display loading states, error messages, and success messages across related operations.

Overview

Key Use Case: When your component performs multiple related operations (like load user details, update user, delete user), MiniStateCombined lets you show a single loading spinner, error message, or success message that represents the combined state of all operations.

User Details State
Update User State
Delete User State
Combined State

Core Methods

Combine

static Combine<T extends MiniState<any, any>[]>(...states: T)

Creates a combined state object that aggregates the state of multiple MiniState instances. The combined state provides signals and observables that reflect the collective state of all the input states.

Utility Methods

CombineLoaders

static CombineLoaders<T extends MiniState<any, any>[]>(...states: T): Signal<boolean>

Creates a signal that is true if any of the input states are currently loading. This is useful for showing a single loading indicator for multiple operations.

CombineErrorMsgs

static CombineErrorMsgs<T extends MiniState<any, any>[]>(...states: T): Signal<string | undefined>

Creates a signal that contains the most recent error message from any of the input states. Only one error message is displayed at a time, prioritizing the most recent.

CombineSuccessMsgs

static CombineSuccessMsgs<T extends MiniState<any, any>[]>(...states: T): Signal<string | undefined>

Creates a signal that contains the most recent success message from any of the input states. Only one success message is displayed at a time, prioritizing the most recent.

CombineData

static CombineData<T extends MiniState<any, any>[]>(...states: T): Signal<any>

Creates a signal that contains the most recent data from any of the input states. This is useful when multiple operations affect the same data model.

CombineErrors

static CombineErrors<T extends MiniState<any, any>[]>(...states: T): Signal<Error | undefined>

Creates a signal that contains the most recent error object from any of the input states. This provides access to the actual error object for custom error handling.

Complete Usage Example

The following example demonstrates a complete user profile component using MiniStateCombined to coordinate multiple user operations: