Commiq Docs
Usage Patterns

Patterns

Architectural patterns and best practices for building with Commiq.

Patterns

These pages cover the recurring architectural decisions in a Commiq application. Each one reflects how the library is designed to be used, including where a pattern has a cost or a limit.

Every snippet uses only exported APIs and is written to be copy-pasted.

Two things that apply everywhere

Declare state fields readonly. Every state-reading surface is typed DeepReadonly<S>, so a mutable Item[] field cannot be spread out of ctx.state and written back — { ...ctx.state, other: 1 } is a compile error. One keyword per field makes both forms of setState work everywhere. See store file structure.

Nothing propagates out of queue() or flush(). Neither ever rejects. A failure is observed through the CommandHandle returned by queue(), through StoreOptions.onError, or through the builtin error events — never through a try/catch at the dispatch site. See error handling.

On this page