diff --git a/hosts/ocaml/lib/sx_primitives.ml b/hosts/ocaml/lib/sx_primitives.ml index f93ea57c..6fdd5d40 100644 --- a/hosts/ocaml/lib/sx_primitives.ml +++ b/hosts/ocaml/lib/sx_primitives.ml @@ -686,6 +686,18 @@ let () = | None -> raise (Eval_error ("Store not found: " ^ name))) | _ -> raise (Eval_error "use-store: expected (name)")); register "clear-stores" (fun _args -> Hashtbl.clear store_registry; Nil); + (* resource — SSR stub: return signal with {loading: true}, client hydrates real fetch *) + register "resource" (fun _args -> + let state = Hashtbl.create 8 in + Hashtbl.replace state "loading" (Bool true); + Hashtbl.replace state "data" Nil; + Hashtbl.replace state "error" Nil; + let sig_d = Hashtbl.create 8 in + Hashtbl.replace sig_d "__signal" (Bool true); + Hashtbl.replace sig_d "value" (Dict state); + Hashtbl.replace sig_d "subscribers" (List []); + Hashtbl.replace sig_d "deps" (List []); + Dict sig_d); register "apply" (fun args -> let call f a = match f with diff --git a/sx/sx/reactive-islands/index.sx b/sx/sx/reactive-islands/index.sx index a41f9f66..4a7bf4b7 100644 --- a/sx/sx/reactive-islands/index.sx +++ b/sx/sx/reactive-islands/index.sx @@ -236,11 +236,12 @@ (~docs/section :title "Examples" :id "examples" - (p "Source for every demo island on this page.") + (p "Each example below shows a live island and its source.") (~docs/section :title "Counter" :id "demo-counter" (p "Signals, computed, and " (code "swap!") ".") + (~reactive-islands/index/demo-counter :initial 0) (~docs/code :src (highlight (component-source "~reactive-islands/index/demo-counter") @@ -252,6 +253,7 @@ "Two signals, each derived from the other via " (code "effect") ".") + (~reactive-islands/index/demo-temperature) (~docs/code :src (highlight (component-source "~reactive-islands/index/demo-temperature") @@ -260,6 +262,7 @@ :title "Imperative Handlers" :id "demo-imperative" (p "Multi-statement " (code "(do ...)") " bodies in event handlers.") + (~reactive-islands/index/demo-imperative) (~docs/code :src (highlight (component-source "~reactive-islands/index/demo-imperative") @@ -272,6 +275,7 @@ " and " (code "clear-interval") " with signal-driven UI.") + (~reactive-islands/index/demo-stopwatch) (~docs/code :src (highlight (component-source "~reactive-islands/index/demo-stopwatch") @@ -280,6 +284,7 @@ :title "Reactive List" :id "demo-reactive-list" (p "Dynamic list with keyed reconciliation.") + (~reactive-islands/index/demo-reactive-list) (~docs/code :src (highlight (component-source "~reactive-islands/index/demo-reactive-list") @@ -288,6 +293,7 @@ :title "Input Binding" :id "demo-input-binding" (p "Two-way binding via " (code ":bind") " attribute.") + (~reactive-islands/index/demo-input-binding) (~docs/code :src (highlight (component-source "~reactive-islands/index/demo-input-binding") @@ -299,6 +305,7 @@ "Reactive class toggling with " (code "deref") " in attribute expressions.") + (~reactive-islands/index/demo-dynamic-class) (~docs/code :src (highlight (component-source "~reactive-islands/index/demo-dynamic-class") @@ -307,6 +314,7 @@ :title "Portal" :id "demo-portal" (p "Render content outside the island's DOM subtree.") + (~reactive-islands/index/demo-portal) (~docs/code :src (highlight (component-source "~reactive-islands/index/demo-portal") @@ -315,6 +323,7 @@ :title "Error Boundary" :id "demo-error-boundary" (p "Catch rendering errors without crashing the page.") + (~reactive-islands/index/demo-error-boundary) (~docs/code :src (highlight (component-source "~reactive-islands/index/demo-error-boundary") @@ -323,6 +332,7 @@ :title "DOM Refs" :id "demo-refs" (p "Access raw DOM elements via " (code ":ref") " signal.") + (~reactive-islands/index/demo-refs) (~docs/code :src (highlight (component-source "~reactive-islands/index/demo-refs") @@ -334,6 +344,7 @@ "Async data fetching with " (code "promise-then") " and loading state.") + (~reactive-islands/index/demo-resource) (~docs/code :src (highlight (component-source "~reactive-islands/index/demo-resource") @@ -347,6 +358,7 @@ " and " (code "batch") ".") + (~reactive-islands/index/demo-transition) (~docs/code :src (highlight (component-source "~reactive-islands/index/demo-transition") @@ -360,10 +372,12 @@ " / " (code "use-store") ".") + (~reactive-islands/index/demo-store-writer) (~docs/code :src (highlight (component-source "~reactive-islands/index/demo-store-writer") "lisp")) + (~reactive-islands/index/demo-store-reader) (~docs/code :src (highlight (component-source "~reactive-islands/index/demo-store-reader") @@ -375,6 +389,7 @@ "Server-rendered content communicating with an island via " (code "bridge-event") ".") + (~reactive-islands/index/demo-event-bridge) (~docs/code :src (highlight (component-source "~reactive-islands/index/demo-event-bridge")