GizStackGizStack
View .mdOpen in ChatGPTOpen in Claude

gizapp/state

how the code that ghtml writes for a page reads its state from the form the page posted (hidden fields and bound controls, _s.NAME), and writes a state of a record or list type into it. An app does not call these: a page declares let NAME: T = INITIAL; and the compiler reads and writes it.

gizlang
import * as State from "gizapp/state";

Functions

text

gizlang
function text(form: Http.Params, name: string, initial: string): string

The state NAME of a page: what the form posted, else INITIAL. The state is in the page (hidden fields and bound controls), not in the server.

Effects: fail, alloc.

integer

gizlang
function integer(form: Http.Params, name: string, initial: i64): i64

The integer state NAME of a page: what the form posted, else INITIAL (also when the posted text is not an integer).

Effects: fail, alloc.

number

gizlang
function number(form: Http.Params, name: string, initial: f64): f64

The number state NAME of a page: what the form posted, else INITIAL (also when the posted text is not a number).

Effects: fail, alloc.

decoded

gizlang
function decoded<T>(form: Http.Params, name: string, initial: T): T

The state NAME of a page of any other type T (a record, a list, an Option): what the form posted, as its JSON, else INITIAL (also when the posted text is not a T).

encoded

gizlang
function encoded<T>(value: T): string

The text of the state VALUE of type T in the page's form and its address: its JSON.

flag

gizlang
function flag(form: Http.Params, name: string, initial: bool): bool

The flag state NAME of a page: what the form posted, else INITIAL.

Effects: fail, alloc.

shown

gizlang
function shown<T>(value: T): string

The text a control bound to a field of a row shows of VALUE: a text as it is, a list one item a line (as Model.listWire reads it back), any other value its JSON (a number, a flag as true or false).