Examples
The distribution includes two kinds of programs: 43 small programs, each explaining one feature, numbered in reading order; and screens that run in a browser.
Every screen comes with an HTML file written by a designer. The LPScript program contains no HTML. It clones sample elements from the HTML, fills in values, and names the message to send when an element is clicked.
One page per screen:
- Orders — search, filter, sort, detail pane, save. Status is a class, not a string
- Order entry — a ViewModel and a field table. Two handlers for the whole form
- Validation — validation rules are read from a file shared with the server
- A screen with no request in it — URL, token, and envelope are in a shared component
- Paging — a list for a server that returns one page at a time
- Quotes — rows and the dialog are cloned from the HTML
- Ten thousand rows — virtual scrolling; about two dozen visible rows are drawn
- Files — receiving and saving files, as text and as bytes
- Overlay — why the overlay for a waiting screen is a separate actor
- Page to page — navigation and read-once value passing
- Workers — the same computation on the main thread and in a Worker
- Supervision — stop one actor with an error and observe the others
- Date picker — a shared component that is not an actor
- Todo list — a parent's redraw does not reach its children
- Games — per-frame drawing in the DOM and on a canvas
Shared components
Components that belong to no screen are kept in separate files and imported by path.
Components that are not actors: the confirmation dialog, the calendar, and the pager. The dialog and the calendar carry their own markup. The pager takes two numbers and returns a page number. None of them holds state, so none depends on the class of the screen using it.
Components that are actors: the overlay shown during a request, and the region where server errors are displayed. A screen waiting at forced is not redrawn while it waits, so a component that must change during the wait cannot be part of the screen's state. It has to be a separate actor.
Others: the gateway (takes a service name and a payload, returns the response body only when the server reports success), validation (reads a rules file shared with the server), the store (splits sessionStorage into values kept for the session and values read once), and the socket (WebSocket with disconnect detection and reconnection).