Poti in kako si lastnosti na isti poti delijo zaslon.
Stran je pot in lastnosti, ki tečejo na njej. Ko se pot odpre, vsaka lastnost enkrat prejme INIT; ko se zapre, se lastnosti sprostijo.
page "/notes" -> NoteList, NoteForm
page "/notes/:id" as NoteDetail -> NoteView
page "/" -> Home [initial]:id je parameter poti; v tovoru INIT strani prispe kot ?id.as Name strani da ime, na katero se lahko sklicujejo drugi orbitali in agenti.[initial] označi začetno stran.Vsaka stran mora biti dosegljiva: povezava, element navigacije ali učinek navigate mora voditi nanjo, sicer jo orb validate sporoči.
Dve lastnosti, ki obe rišeta v main, bi na eno stran zložili dve telesi, kar preverjevalnik zavrne. Namesto tega ju sestavi: lastnost strani nariše postavitev in z @trait.Name vgradi ostale:
1trait LibraryPage -> LibraryView [interaction, instance] {
2 initial: idle
3 state idle {
4 INIT -> idle
5 (render-ui main { type: stack, direction: vertical, gap: lg, children: [@trait.BookFacts, @trait.BookShelf] })
6 }
7}
8
9page "/library" -> LibraryPageVsaka vgrajena lastnost ohrani svoj avtomat stanj in svoje posodobitve; lastnost strani odloča le, kam gredo.
LibraryPage
on LibraryView · states: 1 · transitions: 0BookShelf
on Book · states: 3 · transitions: 9BookFacts
on LibraryView · states: 1 · transitions: 0MasterListView
on Book · states: 1 · transitions: 1books
on loan
Abelson and Sussman
Hoare
Knuth
1app std-orb-docex-library "1.0.0"
2"std-orb-docex-library — composition: two standard behaviors bound to a local entity and configured at the call site, with no state machine written by hand."
3orbital LibraryOrbital {
4 uses Browse from "std/behaviors/std-browse"
5 uses StatBand from "std/behaviors/std-stat-band"
6
7 entity Book [persistent: docex_books, local] {
8 id : string!
9 name : string!
10 author : string = ""
11 status : "active" | "pending" | "inactive" = active
12 instances [
13 { id: "B-1", name: "Structure and Interpretation", author: "Abelson and Sussman", status: active },
14 { id: "B-2", name: "Communicating Sequential Processes", author: "Hoare", status: pending },
15 { id: "B-3", name: "The Art of Computer Programming", author: "Knuth", status: active }
16 ]
17 }
18
19 entity LibraryView [runtime] {
20 id : string!
21 }
22
23 trait LibraryPage -> LibraryView [interaction, instance] {
24 initial: idle
25
26 state idle {
27 INIT -> idle
28 (render-ui main { type: stack, direction: vertical, gap: lg, children: [@trait.BookFacts, @trait.BookShelf] })
29 }
30 }
31
32 trait BookShelf = Browse.traits.BrowseItemBrowse -> Book {
33 config {
34 browseLook: feed
35 bodySearch: false
36 fields: [{ name: "name", label: "Title", variant: h4 }, { name: "author", label: "Author", variant: caption }, { name: "status", label: "Status", variant: badge, labels: { active: "On the shelf", pending: "On loan", inactive: "Lost" } }]
37 }
38 }
39
40 trait BookFacts = StatBand.traits.StatBandRender -> LibraryView {
41 config {
42 heading: "The shelf at a glance"
43 items: [{ value: "3", label: "books" }, { value: "1", label: "on loan" }]
44 }
45 }
46
47 page "/library" -> LibraryPage
48}render-ui riše v imenovano režo. main je telo strani. modal, drawer in dock so plasti nad njo: kar jih odpre, jih mora izprazniti ((render-ui modal null)) na vsaki poti iz stanja, ki jih je odprlo, in preverjevalnik to preveri. toast kaže obvestila; floating je prisoten na vsaki strani.
Zaprti krog poveže dogodke, stanja in zaslone.