Skip to content

Latest commit

 

History

History
12 lines (10 loc) · 943 Bytes

async.md

File metadata and controls

12 lines (10 loc) · 943 Bytes

This doc describes about the behavior with async.

Some notes

  • You need to wrap components with <Suspense> inside <Provider>.
  • You can have as many <Suspense> as you need.
  • If the read function of an atom returns a promise, the atom will suspend.
  • This applies to dependent atoms too.
  • If a primitive atom has a promise as the initial value, it will suspend at the first use (when Provider doesn't have it.)
  • You can create a read function so that it works asynchronously, but does not return a promise. In such a case, the atom won't suspend.
  • If the write function of an atom returns a promise, the atom will suspend. There's no way to know as of now if an atom suspends because of read or write.
  • You can create a write function so that it works asynchronously, but does not return a promise. In such a case, the atom won't suspend. (Caveat: This means you can't catch async errors. So, it's not recommended.)