Skip to content

Commit 9f0411c

Browse files
committed
update docs
1 parent a9ed24c commit 9f0411c

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

packages/shadow-objects/docs/cheat-sheet.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
- Entities are lightweight game objects. Shadow Objects are ECS components that attach behavior to them.
66
- The setup function runs once per entity. Everything reactive goes inside it.
77
- `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.
1010

1111
---
1212

@@ -69,17 +69,17 @@ export default {
6969
```typescript
7070
// Signal: read/write reactive state
7171
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
7575

7676
// Memo: derived value
77-
const doubled = createMemo(() => count() * 2);
77+
const doubled = createMemo(() => count.get() * 2);
7878
doubled() // read
7979

8080
// Effect: runs immediately, re-runs when deps change
8181
createEffect(() => {
82-
console.log('count is', count());
82+
console.log('count is', count.get());
8383
});
8484

8585
// Resource: manage external objects that need cleanup
@@ -123,13 +123,13 @@ export function GameRoot({ provideContext, createSignal }) {
123123
// Consumer: read from nearest ancestor
124124
export function Enemy({ useContext }) {
125125
const currentLevel = useContext('currentLevel');
126-
// if currentLevel is a signal: currentLevel() to read
126+
// currentLevel is a signal reader: currentLevel() to read
127127
}
128128

129129
// Skip self, start from parent
130-
export function Middleware({ useParentContext, provideContext }) {
130+
export function Middleware({ createMemo, useParentContext, provideContext }) {
131131
const upstream = useParentContext('theme');
132-
provideContext('theme', { ...upstream, accent: 'red' });
132+
provideContext('theme', createMemo(() => ({ ...upstream(), accent: 'red' })));
133133
}
134134

135135
// Global (available everywhere, regardless of hierarchy)

packages/shadow-objects/docs/concepts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ export function MyLogic({
165165

166166
onViewEvent((type, data) => {
167167
if (type === 'click') {
168-
count.set(c => c + 1);
168+
count.set(count.value + 1);
169169
}
170170
});
171171

0 commit comments

Comments
 (0)