@audi2014/react-async-concurrent
TypeScript icon, indicating that this package has built-in type declarations

1.0.24 • Public • Published

react-async-concurrent

GitHub license npm version npm

Dummy package for declarative(JSX) sequential promise execution

...
<Async promiseFn={promiseFn}>{render}</Async> // this promiseFn starts at first
<Async promiseFn={promiseFn}>{render}</Async> // starts after finishing first
<Async promiseFn={promiseFn}>{render}</Async> // starts after finishing seccond
...

Index

Async

Component (wrapper) which will put promise result into children (FaCC) or renderResult function

Props

  • renderPending ({status: pending}) - optional callback for rendering pending status: (promiseFn was not called or canceled. Component is waiting for finishing other concurrent promises)
  • renderProgress ({status: progress}) - optional callback for rendering progress status: (promiseFn was called but promise did not fulfilled yet)
  • renderError ({error, status: error}) - optional callback for rendering error status: (promiseFn promise throws error)
  • promiseFn - function callback that should create new promise. will be called if all child promises resolved. supports cancelable promises such as cancelable-promise
  • children - FaCC with arguments {lastResult/result:"Awaited result of promiseFn", status: pending|progress|error|result} if children is set - renderers renderPending/renderProgress/renderError/renderResult will be ignored
  • asyncStart - do not wait for finishing concurrent promises. call promiseFn immediately
  • asyncChildren - children will have parallel concurrent context
  • awaited - promiseFn will not block other concurrent promises

Example

https://qz8j6h.csb.app/

Example


Bugs

  • React.StrictMode runs all promiseFn at first render in codesandbox env

subpath imports support (ESM/CommonJs)

Package Sidebar

Install

npm i @audi2014/react-async-concurrent

Weekly Downloads

0

Version

1.0.24

License

MIT

Unpacked Size

23.5 kB

Total Files

43

Last publish

Collaborators

  • audi2014