API

MiniStateBuilder API Documentation

MiniStateBuilder provides a fluent API for creating MiniState instances with a clean, chainable syntax. It simplifies the process of configuring a MiniState and handles cleanup automatically via DestroyRef.

Core Concept

1. Select Factory Method
MiniStateBuilder.Create()CreateWithInput()CreateWithObservableInput()CreateWithSignalInput()
2. Configure (Optional)
.setSuccessMsgFn(...).setErrorMsgFn(...)
3. Use
.trigger()
MiniState manages state automatically

Factory Methods

Create

static Create<Output>(triggerFn$: () => Observable<Output>, initialOutputValue?: Output)

Creates a MiniState for operations that don't require input parameters (e.g., "get all" operations). The trigger function takes no parameters.

CreateWithInput

static CreateWithInput<Input, Output>(triggerFn$: (input: Input) => Observable<Output>, initialOutputValue?: Output)

Creates a MiniState for operations that require input parameters (e.g., "get by id" or "filtered search"). The trigger function takes one parameter of type Input.

CreateWithObservableInput

static CreateWithObservableInput<Input, Output>(input$: Observable<Input>, triggerFn$: (input: Input) => Observable<Output>, initialOutputValue?: Output)

Creates a MiniState that automatically triggers whenever the input$ Observable emits a new value. Ideal for reacting to router parameters, form values, or other reactive data sources.

CreateWithSignalInput

static CreateWithSignalInput<Input, Output>(input$: Signal<Input>, triggerFn$: (input: Input) => Observable<Output>, initialOutputValue?: Output)

Creates a MiniState that automatically triggers whenever the input$ Signal changes. Similar to CreateWithObservableInput but for Angular's Signal primitive.

Automatic Cleanup

MiniStateBuilder automatically injects DestroyRef and sets up proper cleanup when the component is destroyed. This means you don't need to manually call unsubscribe() - subscriptions are managed for you.

Complete Examples

A weather component that loads current weather data without input parameters: