Skip to content

audi2014/react-async-concurrent

Repository files navigation

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)

About

This is dummy package. This repository was created for exploring github packages functionality

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published