Skip to content

Commit 54bf11c

Browse files
committed
add more
1 parent 7980a3d commit 54bf11c

File tree

11 files changed

+141
-74
lines changed

11 files changed

+141
-74
lines changed

src/routes/reference/reactive-utilities/from.mdx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function from<T>(
1717

1818
```
1919

20-
A helper to make it easier to interop with external producers like RxJS observables or with Svelte Stores.
20+
A helper to make it easier to interop with external producers like RxJS observables or with Svelte Stores.
2121
This basically turns any subscribable (object with a subscribe method) into a Signal and manages subscription and disposal.
2222

2323
```tsx
@@ -36,8 +36,10 @@ const clock = from((set) => {
3636
})
3737
```
3838

39-
## Arguments
39+
## Parameters
4040

41-
| Name | Type | Description |
42-
| :------- | :----------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------- |
43-
| producer | `((setter: (v: T) => T) => () => void) \| { subscribe: (fn: (v: T) => void) => (() => void) \| { unsubscribe: () => void }; }` | The producer function or subscribable object |
41+
### `producer`
42+
43+
**Type**: `((setter: (v: T) => T) => () => void) | { subscribe: (fn: (v: T) => void) => (() => void) | { unsubscribe: () => void }; }`
44+
45+
The producer function or subscribable object.

src/routes/reference/reactive-utilities/index-array.mdx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function indexArray<T, U>(
1212

1313
```
1414

15-
Similar to `mapArray` except it maps by index.
15+
Similar to `mapArray` except it maps by index.
1616
The item is a signal and the index is now the constant.
1717

1818
Underlying helper for the `<Index>` control flow.
@@ -33,9 +33,16 @@ const mapped = indexArray(source, (model) => {
3333
});
3434
```
3535

36-
## Arguments
36+
## Parameters
3737

38-
| Name | Type | Description |
39-
| :---- | :----------------------------- | :-------------------- |
40-
| list | `() => readonly T[]` | The list to map. |
41-
| mapFn | `(v: () => T, i: number) => U` | The mapping function. |
38+
### `list`
39+
40+
**Type**: `() => readonly T[]`
41+
42+
The list to map.
43+
44+
### `mapFn`
45+
46+
**Type**: `(v: () => T, i: number) => U`
47+
48+
The mapping function.

src/routes/reference/reactive-utilities/map-array.mdx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ function mapArray<T, U>(
1212

1313
```
1414

15-
Reactive map helper that caches each item by reference to reduce unnecessary mapping on updates.
16-
It only runs the mapping function once per value and then moves or removes it as needed.
15+
Reactive map helper that caches each item by reference to reduce unnecessary mapping on updates.
16+
It only runs the mapping function once per value and then moves or removes it as needed.
1717
The index argument is a signal. The map function itself is not tracking.
1818

1919
Underlying helper for the `<For>` control flow.
@@ -37,9 +37,16 @@ const mapped = mapArray(source, (model) => {
3737
})
3838
```
3939

40-
## Arguments
40+
## Parameters
4141

42-
| Name | Type | Description |
43-
| :---- | :----------------------------- | :----------------------- |
44-
| list | `() => readonly T[]` | The source array to map. |
45-
| mapFn | `(v: T, i: () => number) => U` | The mapping function. |
42+
### `list`
43+
44+
**Type**: `() => readonly T[]`
45+
46+
The source array to map.
47+
48+
### `mapFn`
49+
50+
**Type**: `(v: T, i: () => number) => U`
51+
52+
The mapping function.

src/routes/reference/reactive-utilities/on-util.mdx

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,22 @@ createEffect(
6161
setState({ a: 4 }); // logs 4
6262
```
6363

64-
## Arguments and options
64+
## Parameters
6565

66-
| Argument | Type | Description |
67-
| :------- | :--------------------------------------------- | :------------------------------------------------ |
68-
| deps | `T` | The dependencies to watch. |
69-
| fn | `(input: T, prevInput: T, prevValue?: U) => U` | The function to run when the dependencies change. |
70-
| options | `{ defer?: boolean }` | Options to configure the effect. |
66+
### `deps`
67+
68+
**Type**: `T`
69+
70+
The dependencies to watch.
71+
72+
### `fn`
73+
74+
**Type**: `(input: T, prevInput: T, prevValue?: U) => U`
75+
76+
The function to run when the dependencies change.
77+
78+
### `options`
79+
80+
**Type**: `{ defer?: boolean }`
81+
82+
Options to configure the effect.

src/routes/reference/secondary-primitives/create-computed.mdx

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,30 @@ function createComputed<T>(fn: (v: T) => T, value?: T): void
99

1010
```
1111

12-
`createComputed` creates a new computation that immediately runs the given function in a tracking scope, thus automatically tracking its dependencies, and automatically reruns the function whenever the dependencies changes.
13-
The function gets called with an argument equal to the value returned from the function's last execution, or on the first call, equal to the optional second argument to `createComputed`.
12+
`createComputed` creates a new computation that immediately runs the given function in a tracking scope, thus automatically tracking its dependencies, and automatically reruns the function whenever the dependencies changes.
13+
The function gets called with an argument equal to the value returned from the function's last execution, or on the first call, equal to the optional second argument to `createComputed`.
1414
Note that the return value of the function is not otherwise exposed; in particular, createComputed has no return value.
1515

16-
`createComputed` is the most immediate form of reactivity in Solid, and is most useful for building other reactive primitives.
17-
For example, some other Solid primitives are built from `createComputed`.
18-
However, it should be used with care, as `createComputed` can easily cause more unnecessary updates than other reactive primitives.
16+
`createComputed` is the most immediate form of reactivity in Solid, and is most useful for building other reactive primitives.
17+
For example, some other Solid primitives are built from `createComputed`.
18+
However, it should be used with care, as `createComputed` can easily cause more unnecessary updates than other reactive primitives.
1919
Before using it, consider the closely related primitives [`createMemo`](/reference/basic-reactivity/create-memo) and [`createRenderEffect`](/reference/secondary-primitives/create-render-effect).
2020

21-
Like `createMemo`, `createComputed` calls its function immediately on updates (unless you're in a [batch](/reference/reactive-utilities/batch), [effect](/reference/basic-reactivity/create-effect), or [transition](/reference/reactive-utilities/use-transition)).
22-
However, while `createMemo` functions should be pure (not set any signals), `createComputed` functions can set signals.
23-
Related, `createMemo` offers a readonly signal for the return value of the function, whereas to do the same with `createComputed` you would need to set a signal within the function.
21+
Like `createMemo`, `createComputed` calls its function immediately on updates (unless you're in a [batch](/reference/reactive-utilities/batch), [effect](/reference/basic-reactivity/create-effect), or [transition](/reference/reactive-utilities/use-transition)).
22+
However, while `createMemo` functions should be pure (not set any signals), `createComputed` functions can set signals.
23+
Related, `createMemo` offers a readonly signal for the return value of the function, whereas to do the same with `createComputed` you would need to set a signal within the function.
2424
If it is possible to use pure functions and `createMemo`, this is likely more efficient, as Solid optimizes the execution order of memo updates, whereas updating a signal within `createComputed` will immediately trigger reactive updates some of which may turn out to be unnecessary.
2525

26-
## Arguments
26+
## Parameters
2727

28-
| Name | Type | Description |
29-
| :------ | :------------ | :----------------------------------------- |
30-
| `fn` | `(v: T) => T` | The function to run in a tracking scope. |
31-
| `value` | `T` | The initial value to pass to the function. |
28+
### `fn`
29+
30+
**Type**: `(v: T) => T`
31+
32+
The function to run in a tracking scope.
33+
34+
### `value`
35+
36+
**Type**: `T`
37+
38+
The initial value to pass to the function.

src/routes/reference/secondary-primitives/create-render-effect.mdx

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ function createRenderEffect<T>(fn: (v: T) => T, value?: T): void
99

1010
```
1111

12-
A render effect is a computation similar to a regular effect (as created by [`createEffect`](/reference/basic-reactivity/create-effect)), but differs in when Solid schedules the first execution of the effect function.
13-
While `createEffect` waits for the current rendering phase to be complete, `createRenderEffect` immediately calls the function.
14-
Thus the effect runs as DOM elements are being created and updated, but possibly before specific elements of interest have been created, and probably before those elements have been connected to the document.
15-
In particular, **refs** will not be set before the initial effect call.
12+
A render effect is a computation similar to a regular effect (as created by [`createEffect`](/reference/basic-reactivity/create-effect)), but differs in when Solid schedules the first execution of the effect function.
13+
While `createEffect` waits for the current rendering phase to be complete, `createRenderEffect` immediately calls the function.
14+
Thus the effect runs as DOM elements are being created and updated, but possibly before specific elements of interest have been created, and probably before those elements have been connected to the document.
15+
In particular, **refs** will not be set before the initial effect call.
1616
Indeed, Solid uses `createRenderEffect` to implement the rendering phase itself, including setting of **refs**.
1717

18-
Reactive updates to render effects are identical to effects: they queue up in response to a reactive change (e.g., a single signal update, or a batch of changes, or collective changes during an entire render phase) and run in a single [`batch`](/reference/reactive-utilities/batch) afterward (together with effects).
18+
Reactive updates to render effects are identical to effects: they queue up in response to a reactive change (e.g., a single signal update, or a batch of changes, or collective changes during an entire render phase) and run in a single [`batch`](/reference/reactive-utilities/batch) afterward (together with effects).
1919
In particular, all signal updates within a render effect are batched.
2020

2121
Here is an example of the behavior. (Compare with the example in [`createEffect`](/reference/basic-reactivity/create-effect).)
@@ -49,9 +49,16 @@ queueMicrotask(() => {
4949

5050
Just like `createEffect`, the effect function gets called with an argument equal to the value returned from the effect function's last execution, or on the first call, equal to the optional second argument of `createRenderEffect`.
5151

52-
## Arguments
52+
## Parameters
5353

54-
| Name | Type | Description |
55-
| :------ | :------------ | :----------------------------------------------------- |
56-
| `fn` | `(v: T) => T` | The effect function to be called. |
57-
| `value` | `T` | The initial value to be passed to the effect function. |
54+
### `fn`
55+
56+
**Type**: `(v: T) => T`
57+
58+
The effect function to be called.
59+
60+
### `value`
61+
62+
**Type**: `T`
63+
64+
The initial value to be passed to the effect function.

src/routes/reference/secondary-primitives/create-selector.mdx

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const isSelected = createSelector(selectedId)
3939
In the code above, each `li` element receives an `active` class
4040
exactly when the corresponding `item.id` is equal to `selectedId()`.
4141
When the `selectedId` signal changes, the `li` element(s) that previously
42-
had previously matching `id` get the `active` class removed, and the
42+
had previously matching `id` get the `active` class removed, and the
4343
`li` element(s) that now have a matching `id` get the `active` class added.
4444
All other `li` elements get skipped, so if `id`s are distinct,
4545
only 2 DOM operations get performed.
@@ -55,9 +55,18 @@ const [selectedId, setSelectedId] = createSignal()
5555
</For>
5656
```
5757

58-
## Arguments
58+
## Parameters
5959

60-
| Name | Type | Description |
61-
| :------- | :------------------------ | :------------------------------------------- |
62-
| `source` | `() => T` | The source signal to get the value from and compare with keys. |
63-
| `fn` | `(a: U, b: T) => boolean` | A function to compare the key and the value, returning whether they should be treated as equal. Default: `===` |
60+
### `source`
61+
62+
**Type**: `() => T`
63+
64+
The source signal to get the value from and compare with keys.
65+
66+
### `fn`
67+
68+
**Type**: `(a: U, b: T) => boolean`
69+
70+
**Default**: `===`
71+
72+
A function to compare the key and the value, returning whether they should be treated as equal.

src/routes/solid-router/reference/data-apis/cache.mdx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,21 @@ The return value is a `CachedFunction`, a function that has the same signature a
9494
This cached function stores the return value using the cache key.
9595
Under most circumstances, this temporarily prevents the passed function from running with the same arguments, even if the created function is called repeatedly.
9696

97-
## Arguments
97+
## Parameters
9898

99-
| argument | type | description |
100-
| -------- | ----------------------- | ------------------------------------------------------------------------- |
101-
| `fn` | `(...args: any) => any` | A function whose return value you'd like to be cached. |
102-
| `name`\* | string | Any arbitrary string that you'd like to use as the rest of the cache key. |
99+
### `fn`
103100

104-
\*Since the internal cache is shared by all the functions using `cache`, the string should be unique for each function passed to `cache`.
101+
**Type**: `(...args: any) => any`
102+
103+
A function whose return value you'd like to be cached.
104+
105+
### `name`
106+
107+
**Type**: string
108+
109+
Any arbitrary string that you'd like to use as the rest of the cache key.
110+
111+
Since the internal cache is shared by all the functions using `cache`, the string should be unique for each function passed to `cache`.
105112
If the same key is used with multiple functions, one function might return the cached result of the other.
106113

107114
## Methods

src/routes/solid-router/reference/data-apis/create-async.mdx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ This is used for debugging purposes.
4848
4949
If true, Solid will wait for the resource to resolve before flushing the stream.
5050
51-
| initialValue | `any` | `undefined` | The initial value of the resource. |
52-
5351
### `initialValue`
5452
5553
The initial value of the resource.

src/routes/solid-router/reference/data-apis/query.mdx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,21 @@ The return value is a `CachedFunction`, a function that has the same signature a
8989
This cached function stores the return value using the cache key.
9090
Under most circumstances, this temporarily prevents the passed function from running with the same arguments, even if the created function is called repeatedly.
9191

92-
## Arguments
92+
## Parameters
9393

94-
| argument | type | description |
95-
| -------- | ----------------------- | ------------------------------------------------------------------------- |
96-
| `fn` | `(...args: any) => any` | A function whose return value you'd like to be cached. |
97-
| `name`\* | string | Any arbitrary string that you'd like to use as the rest of the cache key. |
94+
### `fn`
9895

99-
\*Since the internal cache is shared by all the functions using `query`, the string should be unique for each function passed to `query`.
96+
**Type**: `(...args: any) => any`
97+
98+
A function whose return value you'd like to be cached.
99+
100+
### `name`
101+
102+
**Type**: `string`
103+
104+
Any arbitrary string that you'd like to use as the rest of the cache key.
105+
106+
Since the internal cache is shared by all the functions using `query`, the string should be unique for each function passed to `query`.
100107
If the same key is used with multiple functions, one function might return the cached result of the other.
101108

102109
## Methods

0 commit comments

Comments
 (0)