Skip to content

Commit caa8736

Browse files
committed
update
1 parent 13744eb commit caa8736

File tree

1 file changed

+9
-3
lines changed
  • src/routes/reference/reactive-utilities

1 file changed

+9
-3
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@ Returns an accessor backed by the external source.
6262
## Behavior
6363

6464
- A producer function receives a Solid setter and returns a cleanup function.
65-
- A subscribable source must expose `subscribe()`.
66-
- Returned subscriptions are cleaned up with the owning Solid scope.
65+
- A subscribable source must expose `subscribe()`, and that subscription may return either a cleanup function or an object with `unsubscribe()`.
66+
- Emitted values are not deduplicated by equality.
67+
- Returned subscriptions are cleaned up with the current Solid owner when one exists.
6768
- When `initialValue` is omitted, the accessor can return `undefined`.
6869

6970
## Examples
@@ -73,7 +74,12 @@ Returns an accessor backed by the external source.
7374
```ts
7475
import { from } from "solid-js";
7576

76-
const signal = from(observableSource);
77+
const counter = from({
78+
subscribe(next) {
79+
const interval = setInterval(() => next(Date.now()), 1000);
80+
return () => clearInterval(interval);
81+
},
82+
});
7783
```
7884

7985
### Create an accessor from a producer function

0 commit comments

Comments
 (0)