Alterna · учебный материал

Status and developments

43.2: browser interface status, events and re-painting in PyUI.

Что в этом материале

Содержание и основные понятия

The status is the minimum data set that changes over time. The event reports action, the processor updates the status, then the presentation shows relevance.
event model
DOM API
state → render
01
One closed cycle
Event
User in Action
click
, entry of text, change of flag and press key comes from browser.
Status
Changed data
The processor changes the number, row or sign. It is important to keep the data separate from the signature drawn.
Paint
DOM reflects data
The text, the field value and the availability of the button are re-calculated to the current status.
state = {"count": 0}
# click «+» → state["count"] += 1
# render(state) → на экране новое число
02
Check the chain.
Each button below causes a separate event. The log shows order: event, new state, updated representation.
Status counter
real click
0
03
Limits of responsibility
PyUI describes a safe tree of components that host turns into DOM. A separate browser handler receives
click
,
input
or
change
It's more honest than giving a window model to a desktop library.
First, determine what data should survive one user action.
Name the event:
click
,
input
or
change
.
After changing the data, show the user an understandable result.

Structural map of textbooks