Type to search pages and rules.

Browse pages

Blazor Data and State

This page holds how the Blazor stack realizes the frontend data rules (Frontend data).

Markdown8 provisions

Intent#

This page holds how the Blazor stack realizes the frontend data rules (Frontend data). Every use case runs through Application. State carries a declared classification, loads once at startup, and reports failure explicitly rather than through an absent value.

Standards#

Route use cases through Application#

ruleguidance

Requirement A component MUST invoke an Application handler carrying a Command or Query role suffix rather than compose Domain calls or write storage.

Rationale The handler is the one place a use case exists, so a component composing its own sequence creates a second definition.

litespec/frontend/blazor/data#route-use-cases-through-application

Classify state#

ruleguidance

Requirement A specification introducing state MUST classify it as durable, device-local, or derived.

Rationale Durable state is persisted, versioned, and exported. Device-local state is persisted but excluded from export. Derived state is computed from durable state and never persisted.

litespec/frontend/blazor/data#classify-state

Load persisted state once#

ruleguidance

Requirement Persisted state MUST load once during startup into a typed store that components read from.

Rationale A component reading storage on render turns every frame into an input-output call. A route renders its loading state until the store finishes loading.

litespec/frontend/blazor/data#load-persisted-state-once

Keep derived values single-sourced#

ruleguidance

Requirement A derived value MUST be computed in one place in Domain or Application and consumed everywhere else.

Rationale Recomputing the same value in a component is a defect even when the result currently matches.

litespec/frontend/blazor/data#keep-derived-values-single-sourced

Validate at the boundary#

ruleguidance

Requirement Input validation MUST run in an Application validator returning a typed result.

Rationale A form renders those results rather than restating the rules. A browser-side convenience check improves feedback but cannot be the only enforcement. This realizes litespec/frontend/data#validate-a-form-with-the-generated-schema.

litespec/frontend/blazor/data#validate-at-the-boundary

Make failure explicit#

ruleguidance

Requirement An Application handler MUST return a typed result union covering success and each named failure.

Rationale Signaling failure through null, an empty collection, or a bare boolean forces every caller to guess which failure occurred. This realizes litespec/frontend/data#map-every-failure-to-one-problem-type.

litespec/frontend/blazor/data#make-failure-explicit

Conventions#

Keep forms typed#

conventionguidance

Default Bind a form to a typed model owned by its feature and map that model to an Application command on submission.

Replacement A consumer can replace this default with an explicit local convention.

Rationale Binding to a Domain type or a dictionary loses the contract the form is meant to express. This realizes litespec/frontend/data#keep-schemas-operation-specific.

litespec/frontend/blazor/data#keep-forms-typed

Prefer explicit refresh#

conventionguidance

Default Update the store from a command result rather than re-querying after success.

Replacement A consumer can replace this default with an explicit local convention.

Rationale A component that polls spends work discovering something the result already told it. This realizes litespec/frontend/data#update-the-cache-a-command-changed.

litespec/frontend/blazor/data#prefer-explicit-refresh

Verification#

IDMarkEvidence
litespec/frontend/blazor/data#route-use-cases-through-applicationguidanceDoes any component resolve a Domain service or storage adapter?
litespec/frontend/blazor/data#classify-stateguidanceDoes each specification introducing state name one classification?
litespec/frontend/blazor/data#load-persisted-state-onceguidanceDoes persisted state load before the first render?
litespec/frontend/blazor/data#keep-derived-values-single-sourcedguidanceDoes each derived value have one computation site?
litespec/frontend/blazor/data#validate-at-the-boundaryguidanceDoes each form failure originate from its Application validator?
litespec/frontend/blazor/data#make-failure-explicitguidanceDoes each handler union cover success and every named failure?
litespec/frontend/blazor/data#keep-forms-typedguidanceDoes each form bind a feature-owned model and map to a command?
litespec/frontend/blazor/data#prefer-explicit-refreshguidanceDoes the store update from each result without a follow-up query?