Skip to main content

Generated Store API

Generated Exports

Each domain generates two exports:

ExportTypeUsage
withTasks()Feature functionCompose into custom stores
TaskStoreStandalone storeUse directly via inject()
// task.store.ts
export function withTasks<_>() { return signalStoreFeature(...); }
export const TaskStore = signalStore({ providedIn: 'root' }, withTasks());

See Store Feature Composition for composition examples.

Collection Signals

For GET /api/tasks returning an array:

SignalTypeDescription
tasksValue()TaskModel[]Data array
tasksIsLoading()booleanLoading state
tasksError()Error | undefinedError if failed
tasksHasValue()booleanHas loaded
@Component({
template: `
@if (store.tasksIsLoading()) {
<p>Loading...</p>
} @else {
@for (task of store.tasksValue(); track task.id) {
<div>{{ task.title }}</div>
}
}
`
})
export class TaskListComponent {
store = inject(TaskStore);
}

Query Parameters

For endpoints with query params:

APIDescription
tasksParams()Current params
setTasksParams(params)Update params
// Filter by status
store.setTasksParams({ status: 'pending' });

// Clear filters
store.setTasksParams({});

Detail Signals

For GET /api/tasks/{id}:

APIDescription
selectedTaskId()Currently selected ID
selectTask(id)Set selection
taskDetailValue()Selected item
taskDetailIsLoading()Loading state
// Select an item
store.selectTask('123');

// Access detail
const task = store.taskDetailValue();

// Clear selection
store.selectTask(undefined);

Mutations

For POST/PUT/DELETE operations:

APIDescription
createTask(data)Trigger mutation
createTaskIsPending()Loading state
createTaskResult()Success result
createTaskError()Error if failed
// Create
await store.createTask({ title: 'New Task' });

// Update
await store.updateTask({ id: '123', body: { title: 'Updated' } });

// Delete
await store.deleteTask({ id: '123' });

// All mutations auto-refresh the collection

Auto-Refresh

Mutations automatically reload the related collection on success:

await store.createTask({ title: 'Task' });
// store.tasksValue() now includes the new task

Signal Reference

FeatureSignal Pattern
Store{Name}Store
Featurewith{Names}() (pluralized)
Collection{name}Value, {name}IsLoading, {name}Error
Params{name}Params, set{Name}Params
Detailselected{Name}Id, {name}DetailValue, select{Name}
Mutation{name}, {name}IsPending, {name}Result, {name}Error