Skip to content

Commit f9e1b3c

Browse files
authored
Document wish() paths + conventions (#1968)
1 parent 129a66d commit f9e1b3c

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

docs/common/RECIPES.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,53 @@ Several utility functions are available:
176176
str`Hello, ${user.name}! You have ${notifications.count} new messages.`;
177177
```
178178

179+
- `wish`: Access well-known paths and system data in your space. The wish()
180+
function provides a way to reference common system entities and data through
181+
semantic paths.
182+
183+
Available paths:
184+
185+
- **`"/"`**: Access the root space cell and its properties
186+
```typescript
187+
const spaceConfig = wish("/config");
188+
const nestedData = wish("/nested/deep/data");
189+
```
190+
191+
- **`"#default"`**: Shortcut for `/defaultPattern` - access your default pattern
192+
```typescript
193+
const defaultTitle = wish("#default/title");
194+
const defaultArg = wish("#default/argument/greeting");
195+
```
196+
197+
- **`"#mentionable"`**: Access mentionable items from the backlinks index
198+
(maps to `/defaultPattern/backlinksIndex/mentionable`)
199+
```typescript
200+
const mentionable = wish("#mentionable");
201+
const firstMention = wish("#mentionable/0/name");
202+
```
203+
204+
- **`"#recent"`**: Access recently used charms (maps to `/recentCharms`)
205+
```typescript
206+
const recentCharms = wish("#recent");
207+
const latestCharm = wish("#recent/0/name");
208+
```
209+
210+
- **`"#allCharms"`**: Access all charms in the system
211+
```typescript
212+
const allCharms = wish("#allCharms");
213+
const firstCharm = wish("#allCharms/0/title");
214+
```
215+
216+
- **`"#now"`**: Get the current timestamp (no additional path segments allowed)
217+
```typescript
218+
const timestamp = wish("#now");
219+
```
220+
221+
You can also provide a default value as the second argument:
222+
```typescript
223+
const items = wish("/myItems", []); // Returns [] if /myItems doesn't exist
224+
```
225+
179226
**Important**: These built-in functions can only be called from within a recipe
180227
function, not from handlers, lift, or derive functions. They create nodes in the
181228
reactive graph and cannot be awaited directly.

0 commit comments

Comments
 (0)