File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed
Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @inox-tools/utils ' : minor
3+ ---
4+
5+ Allow ` resolvedAtom ` to batch updates from dependencies
Original file line number Diff line number Diff line change 1- import { computed , type ReadableAtom } from 'nanostores' ;
1+ import { batched , computed , type ReadableAtom } from 'nanostores' ;
22
33type ResolvedArray < T extends any [ ] > = T extends [ infer H , ...infer R ]
44 ? [ Resolved < H > , ...ResolvedArray < R > ]
@@ -76,8 +76,8 @@ function findDependencies(value: unknown): ReadableAtom[] {
7676 * @param value - A value tree that may contain atoms at any depth.
7777 * @returns A readable atom whose value is the deeply-resolved snapshot of the input.
7878 */
79- export function resolvedAtom < T > ( value : T ) : ReadableAtom < Resolved < T > > {
79+ export function resolvedAtom < T > ( value : T , batch = false ) : ReadableAtom < Resolved < T > > {
8080 const dependencies = findDependencies ( value ) ;
8181
82- return computed ( dependencies , ( ) => resolveNested ( value ) ) ;
82+ return ( batch ? batched : computed ) ( dependencies , ( ) => resolveNested ( value ) ) ;
8383}
You can’t perform that action at this time.
0 commit comments