@ersbeth/picoflow 0.2.4 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (248) hide show
  1. package/.cursor/plans/update-js-e795d61b.plan.md +567 -0
  2. package/.gitlab-ci.yml +24 -0
  3. package/.vscode/settings.json +3 -3
  4. package/CHANGELOG.md +51 -0
  5. package/IMPLEMENTATION_GUIDE.md +1578 -0
  6. package/README.md +9 -134
  7. package/biome.json +32 -32
  8. package/dist/picoflow.js +610 -436
  9. package/dist/types/advanced/array.d.ts +0 -6
  10. package/dist/types/advanced/array.d.ts.map +1 -1
  11. package/dist/types/advanced/index.d.ts +5 -5
  12. package/dist/types/advanced/index.d.ts.map +1 -1
  13. package/dist/types/advanced/map.d.ts +114 -23
  14. package/dist/types/advanced/map.d.ts.map +1 -1
  15. package/dist/types/advanced/resource.d.ts +51 -12
  16. package/dist/types/advanced/resource.d.ts.map +1 -1
  17. package/dist/types/advanced/resourceAsync.d.ts +28 -13
  18. package/dist/types/advanced/resourceAsync.d.ts.map +1 -1
  19. package/dist/types/advanced/stream.d.ts +74 -16
  20. package/dist/types/advanced/stream.d.ts.map +1 -1
  21. package/dist/types/advanced/streamAsync.d.ts +69 -15
  22. package/dist/types/advanced/streamAsync.d.ts.map +1 -1
  23. package/dist/types/basic/constant.d.ts +44 -16
  24. package/dist/types/basic/constant.d.ts.map +1 -1
  25. package/dist/types/basic/derivation.d.ts +73 -24
  26. package/dist/types/basic/derivation.d.ts.map +1 -1
  27. package/dist/types/basic/disposable.d.ts +65 -6
  28. package/dist/types/basic/disposable.d.ts.map +1 -1
  29. package/dist/types/basic/effect.d.ts +27 -16
  30. package/dist/types/basic/effect.d.ts.map +1 -1
  31. package/dist/types/basic/index.d.ts +7 -8
  32. package/dist/types/basic/index.d.ts.map +1 -1
  33. package/dist/types/basic/observable.d.ts +62 -13
  34. package/dist/types/basic/observable.d.ts.map +1 -1
  35. package/dist/types/basic/signal.d.ts +35 -6
  36. package/dist/types/basic/signal.d.ts.map +1 -1
  37. package/dist/types/basic/state.d.ts +25 -4
  38. package/dist/types/basic/state.d.ts.map +1 -1
  39. package/dist/types/basic/trackingContext.d.ts +33 -0
  40. package/dist/types/basic/trackingContext.d.ts.map +1 -0
  41. package/dist/types/creators.d.ts +271 -26
  42. package/dist/types/creators.d.ts.map +1 -1
  43. package/dist/types/index.d.ts +60 -7
  44. package/dist/types/index.d.ts.map +1 -1
  45. package/dist/types/solid/converters.d.ts +5 -5
  46. package/dist/types/solid/converters.d.ts.map +1 -1
  47. package/dist/types/solid/index.d.ts +2 -2
  48. package/dist/types/solid/index.d.ts.map +1 -1
  49. package/dist/types/solid/primitives.d.ts +96 -4
  50. package/dist/types/solid/primitives.d.ts.map +1 -1
  51. package/docs/.vitepress/config.mts +110 -0
  52. package/docs/api/classes/FlowArray.md +489 -0
  53. package/docs/api/classes/FlowConstant.md +350 -0
  54. package/docs/api/classes/FlowDerivation.md +334 -0
  55. package/docs/api/classes/FlowEffect.md +100 -0
  56. package/docs/api/classes/FlowMap.md +512 -0
  57. package/docs/api/classes/FlowObservable.md +306 -0
  58. package/docs/api/classes/FlowResource.md +380 -0
  59. package/docs/api/classes/FlowResourceAsync.md +362 -0
  60. package/docs/api/classes/FlowSignal.md +160 -0
  61. package/docs/api/classes/FlowState.md +368 -0
  62. package/docs/api/classes/FlowStream.md +367 -0
  63. package/docs/api/classes/FlowStreamAsync.md +364 -0
  64. package/docs/api/classes/SolidDerivation.md +75 -0
  65. package/docs/api/classes/SolidResource.md +91 -0
  66. package/docs/api/classes/SolidState.md +71 -0
  67. package/docs/api/classes/TrackingContext.md +33 -0
  68. package/docs/api/functions/array.md +58 -0
  69. package/docs/api/functions/constant.md +45 -0
  70. package/docs/api/functions/derivation.md +53 -0
  71. package/docs/api/functions/effect.md +49 -0
  72. package/docs/api/functions/from.md +220 -0
  73. package/docs/api/functions/isDisposable.md +49 -0
  74. package/docs/api/functions/map.md +57 -0
  75. package/docs/api/functions/resource.md +52 -0
  76. package/docs/api/functions/resourceAsync.md +50 -0
  77. package/docs/api/functions/signal.md +36 -0
  78. package/docs/api/functions/state.md +47 -0
  79. package/docs/api/functions/stream.md +53 -0
  80. package/docs/api/functions/streamAsync.md +50 -0
  81. package/docs/api/index.md +118 -0
  82. package/docs/api/interfaces/FlowDisposable.md +65 -0
  83. package/docs/api/interfaces/SolidObservable.md +19 -0
  84. package/docs/api/type-aliases/FlowArrayAction.md +49 -0
  85. package/docs/api/type-aliases/FlowStreamDisposer.md +15 -0
  86. package/docs/api/type-aliases/FlowStreamSetter.md +27 -0
  87. package/docs/api/type-aliases/FlowStreamUpdater.md +32 -0
  88. package/docs/api/type-aliases/NotPromise.md +18 -0
  89. package/docs/api/type-aliases/SolidGetter.md +17 -0
  90. package/docs/api/typedoc-sidebar.json +1 -0
  91. package/docs/examples/examples.md +2313 -0
  92. package/docs/examples/patterns.md +649 -0
  93. package/docs/guide/advanced/disposal.md +426 -0
  94. package/docs/guide/advanced/solidjs.md +221 -0
  95. package/docs/guide/advanced/upgrading.md +464 -0
  96. package/docs/guide/introduction/concepts.md +56 -0
  97. package/docs/guide/introduction/conventions.md +61 -0
  98. package/docs/guide/introduction/getting-started.md +134 -0
  99. package/docs/guide/introduction/lifecycle.md +371 -0
  100. package/docs/guide/primitives/array.md +400 -0
  101. package/docs/guide/primitives/constant.md +380 -0
  102. package/docs/guide/primitives/derivations.md +348 -0
  103. package/docs/guide/primitives/effects.md +458 -0
  104. package/docs/guide/primitives/map.md +387 -0
  105. package/docs/guide/primitives/overview.md +175 -0
  106. package/docs/guide/primitives/resources.md +858 -0
  107. package/docs/guide/primitives/signal.md +259 -0
  108. package/docs/guide/primitives/state.md +368 -0
  109. package/docs/guide/primitives/streams.md +931 -0
  110. package/docs/index.md +47 -0
  111. package/docs/public/logo.svg +1 -0
  112. package/package.json +57 -41
  113. package/src/advanced/array.ts +208 -210
  114. package/src/advanced/index.ts +7 -7
  115. package/src/advanced/map.ts +178 -68
  116. package/src/advanced/resource.ts +87 -43
  117. package/src/advanced/resourceAsync.ts +62 -42
  118. package/src/advanced/stream.ts +113 -50
  119. package/src/advanced/streamAsync.ts +120 -61
  120. package/src/basic/constant.ts +82 -49
  121. package/src/basic/derivation.ts +128 -84
  122. package/src/basic/disposable.ts +74 -15
  123. package/src/basic/effect.ts +85 -77
  124. package/src/basic/index.ts +7 -8
  125. package/src/basic/observable.ts +94 -36
  126. package/src/basic/signal.ts +133 -105
  127. package/src/basic/state.ts +46 -25
  128. package/src/basic/trackingContext.ts +45 -0
  129. package/src/creators.ts +297 -54
  130. package/src/index.ts +96 -43
  131. package/src/solid/converters.ts +186 -67
  132. package/src/solid/index.ts +8 -2
  133. package/src/solid/primitives.ts +167 -65
  134. package/test/array.test.ts +592 -612
  135. package/test/constant.test.ts +31 -33
  136. package/test/derivation.test.ts +531 -536
  137. package/test/effect.test.ts +21 -21
  138. package/test/map.test.ts +233 -137
  139. package/test/resource.test.ts +119 -121
  140. package/test/resourceAsync.test.ts +98 -100
  141. package/test/signal.test.ts +51 -55
  142. package/test/state.test.ts +186 -168
  143. package/test/stream.test.ts +189 -189
  144. package/test/streamAsync.test.ts +186 -186
  145. package/tsconfig.json +19 -18
  146. package/typedoc.json +37 -0
  147. package/vite.config.ts +23 -23
  148. package/vitest.config.ts +7 -7
  149. package/api/doc/index.md +0 -31
  150. package/api/doc/picoflow.array.md +0 -55
  151. package/api/doc/picoflow.constant.md +0 -55
  152. package/api/doc/picoflow.derivation.md +0 -55
  153. package/api/doc/picoflow.effect.md +0 -55
  154. package/api/doc/picoflow.flowarray._constructor_.md +0 -49
  155. package/api/doc/picoflow.flowarray._lastaction.md +0 -13
  156. package/api/doc/picoflow.flowarray.clear.md +0 -17
  157. package/api/doc/picoflow.flowarray.dispose.md +0 -55
  158. package/api/doc/picoflow.flowarray.get.md +0 -19
  159. package/api/doc/picoflow.flowarray.length.md +0 -13
  160. package/api/doc/picoflow.flowarray.md +0 -273
  161. package/api/doc/picoflow.flowarray.pop.md +0 -17
  162. package/api/doc/picoflow.flowarray.push.md +0 -53
  163. package/api/doc/picoflow.flowarray.set.md +0 -53
  164. package/api/doc/picoflow.flowarray.setitem.md +0 -69
  165. package/api/doc/picoflow.flowarray.shift.md +0 -17
  166. package/api/doc/picoflow.flowarray.splice.md +0 -85
  167. package/api/doc/picoflow.flowarray.unshift.md +0 -53
  168. package/api/doc/picoflow.flowarrayaction.md +0 -37
  169. package/api/doc/picoflow.flowconstant._constructor_.md +0 -49
  170. package/api/doc/picoflow.flowconstant.get.md +0 -25
  171. package/api/doc/picoflow.flowconstant.md +0 -88
  172. package/api/doc/picoflow.flowderivation._constructor_.md +0 -49
  173. package/api/doc/picoflow.flowderivation.get.md +0 -23
  174. package/api/doc/picoflow.flowderivation.md +0 -86
  175. package/api/doc/picoflow.flowdisposable.dispose.md +0 -55
  176. package/api/doc/picoflow.flowdisposable.md +0 -43
  177. package/api/doc/picoflow.floweffect._constructor_.md +0 -54
  178. package/api/doc/picoflow.floweffect.dispose.md +0 -21
  179. package/api/doc/picoflow.floweffect.disposed.md +0 -13
  180. package/api/doc/picoflow.floweffect.md +0 -131
  181. package/api/doc/picoflow.flowgetter.md +0 -15
  182. package/api/doc/picoflow.flowmap._lastdeleted.md +0 -21
  183. package/api/doc/picoflow.flowmap._lastset.md +0 -21
  184. package/api/doc/picoflow.flowmap.delete.md +0 -61
  185. package/api/doc/picoflow.flowmap.md +0 -133
  186. package/api/doc/picoflow.flowmap.setat.md +0 -77
  187. package/api/doc/picoflow.flowobservable.get.md +0 -19
  188. package/api/doc/picoflow.flowobservable.md +0 -68
  189. package/api/doc/picoflow.flowobservable.subscribe.md +0 -55
  190. package/api/doc/picoflow.flowresource._constructor_.md +0 -49
  191. package/api/doc/picoflow.flowresource.fetch.md +0 -27
  192. package/api/doc/picoflow.flowresource.get.md +0 -23
  193. package/api/doc/picoflow.flowresource.md +0 -100
  194. package/api/doc/picoflow.flowresourceasync._constructor_.md +0 -49
  195. package/api/doc/picoflow.flowresourceasync.fetch.md +0 -27
  196. package/api/doc/picoflow.flowresourceasync.get.md +0 -23
  197. package/api/doc/picoflow.flowresourceasync.md +0 -100
  198. package/api/doc/picoflow.flowsignal.dispose.md +0 -59
  199. package/api/doc/picoflow.flowsignal.disposed.md +0 -18
  200. package/api/doc/picoflow.flowsignal.md +0 -112
  201. package/api/doc/picoflow.flowsignal.trigger.md +0 -21
  202. package/api/doc/picoflow.flowstate.md +0 -52
  203. package/api/doc/picoflow.flowstate.set.md +0 -61
  204. package/api/doc/picoflow.flowstream._constructor_.md +0 -49
  205. package/api/doc/picoflow.flowstream.dispose.md +0 -21
  206. package/api/doc/picoflow.flowstream.get.md +0 -23
  207. package/api/doc/picoflow.flowstream.md +0 -100
  208. package/api/doc/picoflow.flowstreamasync._constructor_.md +0 -54
  209. package/api/doc/picoflow.flowstreamasync.dispose.md +0 -21
  210. package/api/doc/picoflow.flowstreamasync.get.md +0 -23
  211. package/api/doc/picoflow.flowstreamasync.md +0 -100
  212. package/api/doc/picoflow.flowstreamdisposer.md +0 -13
  213. package/api/doc/picoflow.flowstreamsetter.md +0 -13
  214. package/api/doc/picoflow.flowstreamupdater.md +0 -19
  215. package/api/doc/picoflow.flowwatcher.md +0 -15
  216. package/api/doc/picoflow.from.md +0 -55
  217. package/api/doc/picoflow.from_1.md +0 -55
  218. package/api/doc/picoflow.from_2.md +0 -55
  219. package/api/doc/picoflow.from_3.md +0 -55
  220. package/api/doc/picoflow.from_4.md +0 -55
  221. package/api/doc/picoflow.from_5.md +0 -55
  222. package/api/doc/picoflow.isdisposable.md +0 -55
  223. package/api/doc/picoflow.map.md +0 -59
  224. package/api/doc/picoflow.md +0 -544
  225. package/api/doc/picoflow.resource.md +0 -55
  226. package/api/doc/picoflow.resourceasync.md +0 -55
  227. package/api/doc/picoflow.signal.md +0 -19
  228. package/api/doc/picoflow.solidderivation._constructor_.md +0 -49
  229. package/api/doc/picoflow.solidderivation.get.md +0 -13
  230. package/api/doc/picoflow.solidderivation.md +0 -94
  231. package/api/doc/picoflow.solidgetter.md +0 -13
  232. package/api/doc/picoflow.solidobservable.get.md +0 -13
  233. package/api/doc/picoflow.solidobservable.md +0 -57
  234. package/api/doc/picoflow.solidresource._constructor_.md +0 -49
  235. package/api/doc/picoflow.solidresource.get.md +0 -13
  236. package/api/doc/picoflow.solidresource.latest.md +0 -13
  237. package/api/doc/picoflow.solidresource.md +0 -157
  238. package/api/doc/picoflow.solidresource.refetch.md +0 -13
  239. package/api/doc/picoflow.solidresource.state.md +0 -13
  240. package/api/doc/picoflow.solidstate._constructor_.md +0 -49
  241. package/api/doc/picoflow.solidstate.get.md +0 -13
  242. package/api/doc/picoflow.solidstate.md +0 -115
  243. package/api/doc/picoflow.solidstate.set.md +0 -13
  244. package/api/doc/picoflow.state.md +0 -55
  245. package/api/doc/picoflow.stream.md +0 -55
  246. package/api/doc/picoflow.streamasync.md +0 -55
  247. package/api/picoflow.public.api.md +0 -244
  248. package/api-extractor.json +0 -61
@@ -0,0 +1,45 @@
1
+ [@ersbeth/picoflow](/api/index.md) / constant
2
+
3
+ # Function: constant()
4
+
5
+ ```ts
6
+ function constant<T>(value): FlowConstant<T>;
7
+ ```
8
+
9
+ Defined in: [creators.ts:69](https://gitlab.com/ersbeth-web/picoflow/-/blob/a6cd2e5702b60b87a8efe22e2fe7d2ce3b0ccca4/src/creators.ts#L69)
10
+
11
+ Creates a new reactive constant.
12
+
13
+ ## Type Parameters
14
+
15
+ | Type Parameter | Description |
16
+ | ------ | ------ |
17
+ | `T` | The type of the constant value. |
18
+
19
+ ## Parameters
20
+
21
+ | Parameter | Type | Description |
22
+ | ------ | ------ | ------ |
23
+ | `value` | `T` \| () => `T` | The value or a function that returns the value (for lazy initialization). |
24
+
25
+ ## Returns
26
+
27
+ [`FlowConstant`](/api/classes/FlowConstant.md)\<`T`\>
28
+
29
+ A new instance of [FlowConstant](/api/classes/FlowConstant.md).
30
+
31
+ ## Remarks
32
+
33
+ A constant is an immutable reactive value that never changes after initialization.
34
+ It can be initialized eagerly (direct value) or lazily (function). Use constants for
35
+ configuration, computed-once values, or expensive initialization that should only run once.
36
+
37
+ ## Example
38
+
39
+ ```typescript
40
+ // Eager initialization
41
+ const $config = constant({ apiUrl: 'https://api.example.com' });
42
+
43
+ // Lazy initialization
44
+ const $computed = constant(() => expensiveCalculation());
45
+ ```
@@ -0,0 +1,53 @@
1
+ [@ersbeth/picoflow](/api/index.md) / derivation
2
+
3
+ # Function: derivation()
4
+
5
+ ```ts
6
+ function derivation<T>(fn): FlowDerivation<T>;
7
+ ```
8
+
9
+ Defined in: [creators.ts:272](https://gitlab.com/ersbeth-web/picoflow/-/blob/a6cd2e5702b60b87a8efe22e2fe7d2ce3b0ccca4/src/creators.ts#L272)
10
+
11
+ Creates a new reactive derivation whose value is computed based on other reactive signals.
12
+
13
+ ## Type Parameters
14
+
15
+ | Type Parameter | Description |
16
+ | ------ | ------ |
17
+ | `T` | The type of the derived value. |
18
+
19
+ ## Parameters
20
+
21
+ | Parameter | Type | Description |
22
+ | ------ | ------ | ------ |
23
+ | `fn` | (`t`) => `T` | A function that computes the derived value using a tracking context. |
24
+
25
+ ## Returns
26
+
27
+ [`FlowDerivation`](/api/classes/FlowDerivation.md)\<`T`\>
28
+
29
+ A new instance of [FlowDerivation](/api/classes/FlowDerivation.md).
30
+
31
+ ## Remarks
32
+
33
+ A derivation is a computed reactive value that automatically tracks its dependencies and
34
+ recomputes when they change. The computation is lazy - it runs only when the value is
35
+ accessed, not on construction. Use derivations to create derived state without manual
36
+ dependency management.
37
+
38
+ ## Example
39
+
40
+ ```typescript
41
+ const $firstName = state('John');
42
+ const $lastName = state('Doe');
43
+
44
+ const $fullName = derivation((t) => {
45
+ return `${$firstName.get(t)} ${$lastName.get(t)}`;
46
+ });
47
+
48
+ effect((t) => {
49
+ console.log($fullName.get(t)); // Logs: "John Doe"
50
+ });
51
+
52
+ $firstName.set('Jane'); // Logs: "Jane Doe"
53
+ ```
@@ -0,0 +1,49 @@
1
+ [@ersbeth/picoflow](/api/index.md) / effect
2
+
3
+ # Function: effect()
4
+
5
+ ```ts
6
+ function effect(fn): FlowEffect;
7
+ ```
8
+
9
+ Defined in: [creators.ts:310](https://gitlab.com/ersbeth-web/picoflow/-/blob/a6cd2e5702b60b87a8efe22e2fe7d2ce3b0ccca4/src/creators.ts#L310)
10
+
11
+ Creates a new reactive effect that executes a side-effect function based on its dependencies.
12
+
13
+ ## Parameters
14
+
15
+ | Parameter | Type | Description |
16
+ | ------ | ------ | ------ |
17
+ | `fn` | (`t`) => `void` | A function that performs side effects using a tracking context. |
18
+
19
+ ## Returns
20
+
21
+ [`FlowEffect`](/api/classes/FlowEffect.md)
22
+
23
+ A new instance of [FlowEffect](/api/classes/FlowEffect.md).
24
+
25
+ ## Remarks
26
+
27
+ An effect is a reactive computation that runs immediately and re-runs whenever its tracked
28
+ dependencies change. Use effects for side effects like logging, DOM updates, network requests,
29
+ or any operation that should respond to reactive state changes.
30
+
31
+ The effect executes immediately upon creation and provides a tracking context (`t`) that you
32
+ use to explicitly mark dependencies via `observable.get(t)`. Use `observable.pick()` for
33
+ reads that shouldn't trigger re-runs.
34
+
35
+ ## Example
36
+
37
+ ```typescript
38
+ const $count = state(0);
39
+
40
+ const fx = effect((t) => {
41
+ console.log('Count is:', $count.get(t));
42
+ });
43
+
44
+ $count.set(1); // Logs: "Count is: 1"
45
+ $count.set(2); // Logs: "Count is: 2"
46
+
47
+ // Clean up when done
48
+ fx.dispose();
49
+ ```
@@ -0,0 +1,220 @@
1
+ [@ersbeth/picoflow](/api/index.md) / from
2
+
3
+ # Function: from()
4
+
5
+ Converts a FlowObservable or getter function into a Solid derivation or resource, depending on whether the value is synchronous or asynchronous.
6
+
7
+ ## Param
8
+
9
+ The FlowObservable or getter function to convert.
10
+
11
+ ## Remarks
12
+
13
+ This function bridges PicoFlow's reactive system with SolidJS, allowing you to use
14
+ PicoFlow observables within Solid components. The conversion is automatic based on
15
+ whether the value is a Promise or not:
16
+
17
+ - **FlowObservable of non-Promise value** → SolidDerivation (reactive signal)
18
+ - **FlowObservable of Promise** → SolidResource (async resource)
19
+ - **Getter function returning non-Promise** → SolidDerivation (computed signal)
20
+ - **Getter function returning Promise** → SolidResource (async computed resource)
21
+
22
+ The created Solid primitives automatically subscribe to the PicoFlow observables and
23
+ update when changes occur. The subscription is properly cleaned up when the Solid
24
+ component unmounts.
25
+
26
+ ## Example
27
+
28
+ ```typescript
29
+ import { from } from 'picoflow/solid';
30
+ import { state } from 'picoflow';
31
+
32
+ // Convert a PicoFlow state to a Solid signal
33
+ const $count = state(0);
34
+ const solidCount = from($count);
35
+
36
+ // Use in a Solid component
37
+ function Counter() {
38
+ const count = solidCount.get(); // Solid's reactive get
39
+ return <div>Count: {count}</div>;
40
+ }
41
+
42
+ // Or convert a computation function
43
+ const solidDerived = from((t) => {
44
+ return $count.get(t) * 2;
45
+ });
46
+ ```
47
+
48
+ ## Call Signature
49
+
50
+ ```ts
51
+ function from<T>(flow): SolidResource<NotPromise<T>>;
52
+ ```
53
+
54
+ Defined in: [solid/converters.ts:159](https://gitlab.com/ersbeth-web/picoflow/-/blob/a6cd2e5702b60b87a8efe22e2fe7d2ce3b0ccca4/src/solid/converters.ts#L159)
55
+
56
+ Converts a FlowObservable of a Promise value into a SolidResource.
57
+
58
+ ### Type Parameters
59
+
60
+ | Type Parameter |
61
+ | ------ |
62
+ | `T` |
63
+
64
+ ### Parameters
65
+
66
+ | Parameter | Type | Description |
67
+ | ------ | ------ | ------ |
68
+ | `flow` | [`FlowObservable`](/api/classes/FlowObservable.md)\<`Promise`\<[`NotPromise`](/api/type-aliases/NotPromise.md)\<`T`\>\>\> | The FlowObservable to convert. |
69
+
70
+ ### Returns
71
+
72
+ [`SolidResource`](/api/classes/SolidResource.md)\<[`NotPromise`](/api/type-aliases/NotPromise.md)\<`T`\>\>
73
+
74
+ A SolidResource wrapping the observable.
75
+
76
+ ## Call Signature
77
+
78
+ ```ts
79
+ function from<T>(flow): SolidDerivation<NotPromise<T>>;
80
+ ```
81
+
82
+ Defined in: [solid/converters.ts:170](https://gitlab.com/ersbeth-web/picoflow/-/blob/a6cd2e5702b60b87a8efe22e2fe7d2ce3b0ccca4/src/solid/converters.ts#L170)
83
+
84
+ Converts a FlowObservable of a non-Promise value into a SolidDerivation.
85
+
86
+ ### Type Parameters
87
+
88
+ | Type Parameter |
89
+ | ------ |
90
+ | `T` |
91
+
92
+ ### Parameters
93
+
94
+ | Parameter | Type | Description |
95
+ | ------ | ------ | ------ |
96
+ | `flow` | [`FlowObservable`](/api/classes/FlowObservable.md)\<[`NotPromise`](/api/type-aliases/NotPromise.md)\<`T`\>\> | The FlowObservable to convert. |
97
+
98
+ ### Returns
99
+
100
+ [`SolidDerivation`](/api/classes/SolidDerivation.md)\<[`NotPromise`](/api/type-aliases/NotPromise.md)\<`T`\>\>
101
+
102
+ A SolidDerivation wrapping the observable.
103
+
104
+ ## Call Signature
105
+
106
+ ```ts
107
+ function from<T>(flow):
108
+ | SolidDerivation<NotPromise<T>>
109
+ | SolidResource<NotPromise<T>>;
110
+ ```
111
+
112
+ Defined in: [solid/converters.ts:181](https://gitlab.com/ersbeth-web/picoflow/-/blob/a6cd2e5702b60b87a8efe22e2fe7d2ce3b0ccca4/src/solid/converters.ts#L181)
113
+
114
+ Converts a FlowObservable into a Solid derivation or resource, depending on whether the value is synchronous or asynchronous.
115
+
116
+ ### Type Parameters
117
+
118
+ | Type Parameter |
119
+ | ------ |
120
+ | `T` |
121
+
122
+ ### Parameters
123
+
124
+ | Parameter | Type | Description |
125
+ | ------ | ------ | ------ |
126
+ | `flow` | \| [`FlowObservable`](/api/classes/FlowObservable.md)\<`Promise`\<[`NotPromise`](/api/type-aliases/NotPromise.md)\<`T`\>\>\> \| [`FlowObservable`](/api/classes/FlowObservable.md)\<[`NotPromise`](/api/type-aliases/NotPromise.md)\<`T`\>\> | The FlowObservable to convert. |
127
+
128
+ ### Returns
129
+
130
+ \| [`SolidDerivation`](/api/classes/SolidDerivation.md)\<[`NotPromise`](/api/type-aliases/NotPromise.md)\<`T`\>\>
131
+ \| [`SolidResource`](/api/classes/SolidResource.md)\<[`NotPromise`](/api/type-aliases/NotPromise.md)\<`T`\>\>
132
+
133
+ A SolidDerivation or SolidResource, depending on the input type.
134
+
135
+ ## Call Signature
136
+
137
+ ```ts
138
+ function from<T>(flow): SolidDerivation<NotPromise<T>>;
139
+ ```
140
+
141
+ Defined in: [solid/converters.ts:192](https://gitlab.com/ersbeth-web/picoflow/-/blob/a6cd2e5702b60b87a8efe22e2fe7d2ce3b0ccca4/src/solid/converters.ts#L192)
142
+
143
+ Converts a getter function returning a non-Promise value into a SolidDerivation.
144
+
145
+ ### Type Parameters
146
+
147
+ | Type Parameter |
148
+ | ------ |
149
+ | `T` |
150
+
151
+ ### Parameters
152
+
153
+ | Parameter | Type | Description |
154
+ | ------ | ------ | ------ |
155
+ | `flow` | (`t`) => [`NotPromise`](/api/type-aliases/NotPromise.md)\<`T`\> | The getter function to convert. |
156
+
157
+ ### Returns
158
+
159
+ [`SolidDerivation`](/api/classes/SolidDerivation.md)\<[`NotPromise`](/api/type-aliases/NotPromise.md)\<`T`\>\>
160
+
161
+ A SolidDerivation wrapping the getter.
162
+
163
+ ## Call Signature
164
+
165
+ ```ts
166
+ function from<T>(flow): SolidResource<NotPromise<T>>;
167
+ ```
168
+
169
+ Defined in: [solid/converters.ts:203](https://gitlab.com/ersbeth-web/picoflow/-/blob/a6cd2e5702b60b87a8efe22e2fe7d2ce3b0ccca4/src/solid/converters.ts#L203)
170
+
171
+ Converts a getter function returning a Promise into a SolidResource.
172
+
173
+ ### Type Parameters
174
+
175
+ | Type Parameter |
176
+ | ------ |
177
+ | `T` |
178
+
179
+ ### Parameters
180
+
181
+ | Parameter | Type | Description |
182
+ | ------ | ------ | ------ |
183
+ | `flow` | (`t`) => `Promise`\<[`NotPromise`](/api/type-aliases/NotPromise.md)\<`T`\>\> | The getter function to convert. |
184
+
185
+ ### Returns
186
+
187
+ [`SolidResource`](/api/classes/SolidResource.md)\<[`NotPromise`](/api/type-aliases/NotPromise.md)\<`T`\>\>
188
+
189
+ A SolidResource wrapping the getter.
190
+
191
+ ## Call Signature
192
+
193
+ ```ts
194
+ function from<T>(flow):
195
+ | SolidDerivation<T>
196
+ | SolidResource<T>;
197
+ ```
198
+
199
+ Defined in: [solid/converters.ts:214](https://gitlab.com/ersbeth-web/picoflow/-/blob/a6cd2e5702b60b87a8efe22e2fe7d2ce3b0ccca4/src/solid/converters.ts#L214)
200
+
201
+ Converts a getter function into a Solid derivation or resource, depending on whether the returned value is synchronous or asynchronous.
202
+
203
+ ### Type Parameters
204
+
205
+ | Type Parameter |
206
+ | ------ |
207
+ | `T` |
208
+
209
+ ### Parameters
210
+
211
+ | Parameter | Type | Description |
212
+ | ------ | ------ | ------ |
213
+ | `flow` | \| (`t`) => [`NotPromise`](/api/type-aliases/NotPromise.md)\<`T`\> \| (`t`) => `Promise`\<[`NotPromise`](/api/type-aliases/NotPromise.md)\<`T`\>\> | The getter function to convert. |
214
+
215
+ ### Returns
216
+
217
+ \| [`SolidDerivation`](/api/classes/SolidDerivation.md)\<`T`\>
218
+ \| [`SolidResource`](/api/classes/SolidResource.md)\<`T`\>
219
+
220
+ A SolidDerivation or SolidResource, depending on the input type.
@@ -0,0 +1,49 @@
1
+ [@ersbeth/picoflow](/api/index.md) / isDisposable
2
+
3
+ # Function: isDisposable()
4
+
5
+ ```ts
6
+ function isDisposable(obj): obj is FlowDisposable;
7
+ ```
8
+
9
+ Defined in: [basic/disposable.ts:80](https://gitlab.com/ersbeth-web/picoflow/-/blob/a6cd2e5702b60b87a8efe22e2fe7d2ce3b0ccca4/src/basic/disposable.ts#L80)
10
+
11
+ Type guard that checks whether an object implements the FlowDisposable interface.
12
+
13
+ ## Parameters
14
+
15
+ | Parameter | Type | Description |
16
+ | ------ | ------ | ------ |
17
+ | `obj` | `unknown` | The object to test for disposability. |
18
+
19
+ ## Returns
20
+
21
+ `obj is FlowDisposable`
22
+
23
+ True if the object has a `dispose` method and is therefore disposable, false otherwise.
24
+
25
+ ## Remarks
26
+
27
+ This utility function is useful for safely checking if an object needs disposal before
28
+ attempting cleanup operations. It performs a runtime check for the presence of a `dispose`
29
+ method, making it safe to use with unknown types.
30
+
31
+ **Common Use Cases:**
32
+ - Conditionally disposing items in collections (arrays, maps)
33
+ - Generic cleanup functions that handle both disposable and non-disposable objects
34
+ - Defensive programming when working with mixed types
35
+
36
+ ## Example
37
+
38
+ ```typescript
39
+ function cleanupArray<T>(items: T[]) {
40
+ items.forEach(item => {
41
+ if (isDisposable(item)) {
42
+ item.dispose();
43
+ }
44
+ });
45
+ }
46
+
47
+ const mixed = [state(1), "string", signal(), 42];
48
+ cleanupArray(mixed); // Only disposes the state and signal
49
+ ```
@@ -0,0 +1,57 @@
1
+ [@ersbeth/picoflow](/api/index.md) / map
2
+
3
+ # Function: map()
4
+
5
+ ```ts
6
+ function map<K, V>(initial?): FlowMap<K, V>;
7
+ ```
8
+
9
+ Defined in: [creators.ts:349](https://gitlab.com/ersbeth-web/picoflow/-/blob/a6cd2e5702b60b87a8efe22e2fe7d2ce3b0ccca4/src/creators.ts#L349)
10
+
11
+ Creates a new reactive map state with fine-grained tracking of operations.
12
+
13
+ ## Type Parameters
14
+
15
+ | Type Parameter | Description |
16
+ | ------ | ------ |
17
+ | `K` *extends* `string` \| `number` \| `symbol` | The type of the keys. |
18
+ | `V` | The type of the values. |
19
+
20
+ ## Parameters
21
+
22
+ | Parameter | Type | Description |
23
+ | ------ | ------ | ------ |
24
+ | `initial?` | `Record`\<`K`, `V`\> | An optional record of key-value pairs to initialize the map. |
25
+
26
+ ## Returns
27
+
28
+ [`FlowMap`](/api/classes/FlowMap.md)\<`K`, `V`\>
29
+
30
+ A new instance of [FlowMap](/api/classes/FlowMap.md).
31
+
32
+ ## Remarks
33
+
34
+ A reactive map wraps a native JavaScript Map and provides multiple levels of reactivity:
35
+ tracking the entire map, tracking individual set operations, and tracking individual
36
+ delete operations. The initial record (if provided) is converted to a native Map.
37
+
38
+ ## Example
39
+
40
+ ```typescript
41
+ const $users = map<string, User>({
42
+ 'user1': { name: 'John', age: 30 }
43
+ });
44
+
45
+ // Track the whole map
46
+ effect((t) => {
47
+ console.log('Users:', $users.get(t).size);
48
+ });
49
+
50
+ // Track additions
51
+ effect((t) => {
52
+ const { key, value } = $users.$lastSet.get(t);
53
+ if (key) console.log(`Added: ${key}`);
54
+ });
55
+
56
+ $users.setAt('user2', { name: 'Jane', age: 25 });
57
+ ```
@@ -0,0 +1,52 @@
1
+ [@ersbeth/picoflow](/api/index.md) / resource
2
+
3
+ # Function: resource()
4
+
5
+ ```ts
6
+ function resource<T>(fn): FlowResource<T>;
7
+ ```
8
+
9
+ Defined in: [creators.ts:132](https://gitlab.com/ersbeth-web/picoflow/-/blob/a6cd2e5702b60b87a8efe22e2fe7d2ce3b0ccca4/src/creators.ts#L132)
10
+
11
+ Creates a new reactive resource that asynchronously fetches its value, returning `T | undefined`.
12
+
13
+ ## Type Parameters
14
+
15
+ | Type Parameter | Description |
16
+ | ------ | ------ |
17
+ | `T` | The type of the resource value. |
18
+
19
+ ## Parameters
20
+
21
+ | Parameter | Type | Description |
22
+ | ------ | ------ | ------ |
23
+ | `fn` | () => `Promise`\<`T`\> | An asynchronous function that fetches the resource value. |
24
+
25
+ ## Returns
26
+
27
+ [`FlowResource`](/api/classes/FlowResource.md)\<`T`\>
28
+
29
+ A new instance of [FlowResource](/api/classes/FlowResource.md).
30
+
31
+ ## Remarks
32
+
33
+ A resource manages async data fetching with reactive updates. Unlike [resourceAsync](/api/functions/resourceAsync.md),
34
+ this returns the resolved value directly (or `undefined` if not fetched yet), making it
35
+ easier to work with in synchronous contexts. Call `fetch()` to trigger the async operation.
36
+
37
+ ## Example
38
+
39
+ ```typescript
40
+ const $user = resource(() => fetch('/api/user').then(r => r.json()));
41
+
42
+ // Trigger fetch
43
+ await $user.fetch();
44
+
45
+ // Use in effect
46
+ effect((t) => {
47
+ const user = $user.get(t);
48
+ if (user) {
49
+ console.log(user.name);
50
+ }
51
+ });
52
+ ```
@@ -0,0 +1,50 @@
1
+ [@ersbeth/picoflow](/api/index.md) / resourceAsync
2
+
3
+ # Function: resourceAsync()
4
+
5
+ ```ts
6
+ function resourceAsync<T>(fn): FlowResourceAsync<T>;
7
+ ```
8
+
9
+ Defined in: [creators.ts:164](https://gitlab.com/ersbeth-web/picoflow/-/blob/a6cd2e5702b60b87a8efe22e2fe7d2ce3b0ccca4/src/creators.ts#L164)
10
+
11
+ Creates a new reactive asynchronous resource that always returns a Promise.
12
+
13
+ ## Type Parameters
14
+
15
+ | Type Parameter | Description |
16
+ | ------ | ------ |
17
+ | `T` | The type of the resource value. |
18
+
19
+ ## Parameters
20
+
21
+ | Parameter | Type | Description |
22
+ | ------ | ------ | ------ |
23
+ | `fn` | () => `Promise`\<`T`\> | An asynchronous function that fetches the resource value. |
24
+
25
+ ## Returns
26
+
27
+ [`FlowResourceAsync`](/api/classes/FlowResourceAsync.md)\<`T`\>
28
+
29
+ A new instance of [FlowResourceAsync](/api/classes/FlowResourceAsync.md).
30
+
31
+ ## Remarks
32
+
33
+ An async resource manages async data fetching and always returns a Promise, making it
34
+ ideal for async/await patterns. Unlike [resource](/api/functions/resource.md), the Promise is created lazily
35
+ on first access and cached. Call `fetch()` to create a new Promise and trigger a refetch.
36
+
37
+ ## Example
38
+
39
+ ```typescript
40
+ const $data = resourceAsync(() => fetch('/api/data').then(r => r.json()));
41
+
42
+ // Use with async/await
43
+ effect(async (t) => {
44
+ const data = await $data.get(t);
45
+ console.log(data);
46
+ });
47
+
48
+ // Refetch
49
+ await $data.fetch();
50
+ ```
@@ -0,0 +1,36 @@
1
+ [@ersbeth/picoflow](/api/index.md) / signal
2
+
3
+ # Function: signal()
4
+
5
+ ```ts
6
+ function signal(): FlowSignal;
7
+ ```
8
+
9
+ Defined in: [creators.ts:42](https://gitlab.com/ersbeth-web/picoflow/-/blob/a6cd2e5702b60b87a8efe22e2fe7d2ce3b0ccca4/src/creators.ts#L42)
10
+
11
+ Creates a new reactive signal.
12
+
13
+ ## Returns
14
+
15
+ [`FlowSignal`](/api/classes/FlowSignal.md)
16
+
17
+ A new instance of [FlowSignal](/api/classes/FlowSignal.md).
18
+
19
+ ## Remarks
20
+
21
+ A signal is the simplest reactive primitive - it doesn't hold a value, but can be triggered
22
+ to notify dependent effects and derivations. Use signals when you need event-like notifications
23
+ without associated data.
24
+
25
+ ## Example
26
+
27
+ ```typescript
28
+ const $refresh = signal();
29
+
30
+ effect((t) => {
31
+ $refresh.watch(t);
32
+ console.log('Refreshing...');
33
+ });
34
+
35
+ $refresh.trigger(); // Logs: "Refreshing..."
36
+ ```
@@ -0,0 +1,47 @@
1
+ [@ersbeth/picoflow](/api/index.md) / state
2
+
3
+ # Function: state()
4
+
5
+ ```ts
6
+ function state<T>(value): FlowState<T>;
7
+ ```
8
+
9
+ Defined in: [creators.ts:98](https://gitlab.com/ersbeth-web/picoflow/-/blob/a6cd2e5702b60b87a8efe22e2fe7d2ce3b0ccca4/src/creators.ts#L98)
10
+
11
+ Creates a new reactive state holding a mutable value.
12
+
13
+ ## Type Parameters
14
+
15
+ | Type Parameter | Description |
16
+ | ------ | ------ |
17
+ | `T` | The type of the state value. |
18
+
19
+ ## Parameters
20
+
21
+ | Parameter | Type | Description |
22
+ | ------ | ------ | ------ |
23
+ | `value` | `T` \| () => `T` | The initial value for the state, or a function returning the initial value. |
24
+
25
+ ## Returns
26
+
27
+ [`FlowState`](/api/classes/FlowState.md)\<`T`\>
28
+
29
+ A new instance of [FlowState](/api/classes/FlowState.md).
30
+
31
+ ## Remarks
32
+
33
+ State is the most common reactive primitive - a mutable container that notifies dependents
34
+ when its value changes. Use `set()` to update the value and `get(t)` or `pick()` to read it.
35
+
36
+ ## Example
37
+
38
+ ```typescript
39
+ const $count = state(0);
40
+
41
+ effect((t) => {
42
+ console.log($count.get(t));
43
+ });
44
+
45
+ $count.set(1); // Logs: 1
46
+ $count.set(n => n + 1); // Logs: 2
47
+ ```