You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(useAsyncIter): allow initial value to be a function, called once on mount (#48)
* allow initial value to be a function, called once on mount
* introduce `MaybeFunction` type to clean up places accepting a value-or-function types of inputs
// TODO: The initial values should be able to be given as functions, having them called once on mount
17
-
18
19
/**
19
20
* `useAsyncIter` hooks up a single async iterable value to your component and its lifecycle.
20
21
*
@@ -62,7 +63,7 @@ export { useAsyncIter, type IterationResult };
62
63
* @template TInitVal The type of the initial value, defaults to `undefined`.
63
64
*
64
65
* @param input Any async iterable or plain value.
65
-
* @param initialVal Any initial value for the hook to return prior to resolving the ___first emission___ of the ___first given___ async iterable, defaults to `undefined`.
66
+
* @param initialVal Any optional starting value for the hook to return prior to the ___first yield___ of the ___first given___ async iterable, defaults to `undefined`. You can pass an actual value, or a function that returns a value (which the hook will call once during mounting).
66
67
*
67
68
* @returns An object with properties reflecting the current state of the iterated async iterable or plain value provided via `input` (see {@link IterationResult `IterationResult`}).
68
69
*
@@ -100,7 +101,10 @@ export { useAsyncIter, type IterationResult };
0 commit comments