front.data_binding#
Data-binding primitives that connect front element values to a backing state store.
A BoundData wraps a keyed slot in a State so an
element can read and write its current value through a single object. The
ValueNotSet / Empty sentinels distinguish “no value yet” from a
deliberate empty value.
Classes
|
Expose keys of |
|
A read/write handle on one key ( |
- class front.data_binding.Binder(front_state)[source]#
Bases:
objectExpose keys of
front_stateas attributes (or items) that areBoundDatahandles.Reading an unknown attribute creates a handle for that key (without writing to the state); assigning to it creates the handle and writes the value.
>>> state = {} >>> b = Binder(state) >>> b.foo.get() ValueNotSet >>> b.foo = 42 >>> b.foo(), state (42, {'foo': 42}) >>> b['bar'] = 'hi' >>> state {'foo': 42, 'bar': 'hi'}
See also
front.state.mk_binder: a descriptor-based variant with an allow-list of names.
- class front.data_binding.BoundData(id, state)[source]#
Bases:
objectA read/write handle on one key (
id) of a state mapping.getreturnsValueNotSetwhile the key is absent;setwrites through to the state. Calling the instance is the same asget.>>> state = {} >>> bound = BoundData('x', state) >>> bound.get() ValueNotSet >>> bound.set(3) >>> bound(), state (3, {'x': 3})
See also
Binder: makesBoundDatahandles on demand, as attributes.