Schema declarations on the Application state allows Framework to handle complex serialisation
scenarios, while also allowing your IDE and toolchains to provide autocomplete and type checking.
import writer as wfclass AppSchema(wf.WriterState): counter: intinitial_state = wf.init_state({ "counter": 0}, schema=AppSchema)# Event handler# It receives the session state as an argument and mutates itdef increment(state: AppSchema): state.counter += 1
Accessing an attribute by its key is always possible.
Some components like Vega Lite Chart require specifying a graph in the form of a multi-level dictionary.A schema allows you to specify that an attribute which contains a dictionary
must be treated as a dictionary, rather than as a group of state.