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.
import * as State from "gizapp/state";Functions
text
function text(form: Http.Params, name: string, initial: string): stringThe 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
function integer(form: Http.Params, name: string, initial: i64): i64The 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
function number(form: Http.Params, name: string, initial: f64): f64The 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
function decoded<T>(form: Http.Params, name: string, initial: T): TThe 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
function encoded<T>(value: T): stringThe text of the state VALUE of type T in the page's form and its address: its JSON.
flag
function flag(form: Http.Params, name: string, initial: bool): boolThe flag state NAME of a page: what the form posted, else INITIAL.
Effects: fail, alloc.
shown
function shown<T>(value: T): stringThe 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).