|
5 | 5 | - Entities are lightweight game objects. Shadow Objects are ECS components that attach behavior to them. |
6 | 6 | - The setup function runs once per entity. Everything reactive goes inside it. |
7 | 7 | - `useProperty` reads from the view. `dispatchMessageToView` writes back. Events connect them. |
8 | | -- Local = main thread (great for debugging). Remote = web worker (great for production). |
9 | | -- Shadow Objects is the logic layer. React/Vue/Svelte is the render layer. They work together. |
| 8 | +- Local = main thread (great for webgl, webgpu based apps or debugging). Remote = web worker (great for production). |
| 9 | +- Shadow Objects is the logic layer. React/Vue/Svelte/Html is the render layer. They work together. |
10 | 10 |
|
11 | 11 | --- |
12 | 12 |
|
@@ -69,17 +69,17 @@ export default { |
69 | 69 | ```typescript |
70 | 70 | // Signal: read/write reactive state |
71 | 71 | const count = createSignal(0); |
72 | | -count() // read |
73 | | -count.set(5) // write |
74 | | -count.set(n => n + 1) // update |
| 72 | +count.get() // read |
| 73 | +count.set(5) // write |
| 74 | +count.set(count.value + 1) // update |
75 | 75 |
|
76 | 76 | // Memo: derived value |
77 | | -const doubled = createMemo(() => count() * 2); |
| 77 | +const doubled = createMemo(() => count.get() * 2); |
78 | 78 | doubled() // read |
79 | 79 |
|
80 | 80 | // Effect: runs immediately, re-runs when deps change |
81 | 81 | createEffect(() => { |
82 | | - console.log('count is', count()); |
| 82 | + console.log('count is', count.get()); |
83 | 83 | }); |
84 | 84 |
|
85 | 85 | // Resource: manage external objects that need cleanup |
@@ -123,13 +123,13 @@ export function GameRoot({ provideContext, createSignal }) { |
123 | 123 | // Consumer: read from nearest ancestor |
124 | 124 | export function Enemy({ useContext }) { |
125 | 125 | const currentLevel = useContext('currentLevel'); |
126 | | - // if currentLevel is a signal: currentLevel() to read |
| 126 | + // currentLevel is a signal reader: currentLevel() to read |
127 | 127 | } |
128 | 128 |
|
129 | 129 | // Skip self, start from parent |
130 | | -export function Middleware({ useParentContext, provideContext }) { |
| 130 | +export function Middleware({ createMemo, useParentContext, provideContext }) { |
131 | 131 | const upstream = useParentContext('theme'); |
132 | | - provideContext('theme', { ...upstream, accent: 'red' }); |
| 132 | + provideContext('theme', createMemo(() => ({ ...upstream(), accent: 'red' }))); |
133 | 133 | } |
134 | 134 |
|
135 | 135 | // Global (available everywhere, regardless of hierarchy) |
|
0 commit comments