From 6ea4361d0365c7d2baf59cbeec26efdcfd8d331f Mon Sep 17 00:00:00 2001 From: David Maskasky Date: Mon, 16 Oct 2023 17:04:54 -0700 Subject: [PATCH] doc: remove async from jotai-effect documentation (#2189) Co-authored-by: David Maskasky --- docs/integrations/effect.mdx | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/docs/integrations/effect.mdx b/docs/integrations/effect.mdx index 7491b63e9c..7a7c3a0144 100644 --- a/docs/integrations/effect.mdx +++ b/docs/integrations/effect.mdx @@ -22,10 +22,7 @@ yarn add jotai-effect ```ts type CleanupFn = () => void -type EffectFn = ( - get: Getter, - set: Setter -) => CleanupFn | void | Promise +type EffectFn = (get: Getter, set: Setter) => CleanupFn | void function atomEffect(effectFn: EffectFn): Atom ``` @@ -229,28 +226,6 @@ Aside from mount events, the effect runs when any of its dependencies change val -- **Async:** - For effects that return a promise, all atoms accessed with `get` prior to the returned promise resolving are added to the atom's internal dependency map. Atoms that have been watched after the promise has resolved, for instance in a `setTimeout`, are not included in the dependency map. - - ⚠️ Use [caution](https://github.com/jotaijs/jotai-effect/discussions/10) when using async effects - - -
- Example - - ```js - atomEffect(async (get, set) => { - await new Promise((resolve) => setTimeout(resolve, 1000)) - // updates whenever `anAtom` changes value but not when `anotherAtom` changes value - get(anAtom) - setTimeout(() => { - get(anotherAtom) - }, 5000) - }) - ``` - -
- - **Cleanup:** Accessing atoms with `get` in the cleanup function does not add them to the atom's internal dependency map.