async-library / future Goto Github PK
View Code? Open in Web Editor NEWThe future of React Async and react-async-hook
The future of React Async and react-async-hook
We should settle on a general direction for package structure and naming. This issue is not for discussing package details, but to discuss where to cut them up or merge them. Refer to packages/react-async/src
for an overview of what's currently there. The goal is to offer a way to later add new features without affecting the existing functionality, by using separate packages.
Current idea:
@async-library/core
Core features, library agnostic: reducer, status, globalScope@async-library/devtools
Chrome DevTools extension, supports all libraries@async-library/react-async-component
React Component with Render Props API (<Async>
) and its helper subcomponents (aka classic React Async)@async-library/react-async-hook
React Hook (useAsync
) and standalone helpers@async-library/react-fetch-hook
React Hook (useFetch
), depends on react-async-hook
@async-library/vue-async-composition
Vue.js Composition, following the Vue Composition APIQuestions:
Let's collect and decide on the uses cases and features we want to support with Async Library, either directly or through a separate package. They are grouped, but in no particular order. Core would be @async-library/core
, Integrations would be e.g. @async-library/react-hook
. User provided would be through passing a prop/option. Plugins would be separate packages.
โ๏ธ Core
run(arg1, arg2)
, to support dynamic requests).๐งฉ Integration
๐ User provided / plugin
@async-library/core
will contain all the core functionality that Async Library provides. It will generally not be used directly, but be a dependency of @async-library/react-async-hook
for example. It should have feature parity with react-async
and react-async-hook
(outside of React specifics).
This description is updated as the discussion unfolds.
To discuss:
States:
initial
nothing happened yet (or reinitialize
was invoked)pending
promise is loading or pausedfulfilled
promise was fulfilled with datarejected
promise was rejected with errorConfig options:
fn
async function that will be invoked on run
runOnInit
flag to enable running on init (mount) [do we really need this?]initialValue
initialize value to a predefined value or error [should this be separate values for data and error?]Callback options:
onInit
when first initialized (i.e. mount)onData
when promise has fulfilled with dataonError
when promise has rejected with erroronAbort
when promise has abortedonDestroy
when destroying the instance (i.e. unmount)Actions:
run
invoke fn
abort
cancel a pending promise and invoke AbortController::abort
reinitialize
abort and reset state to initial
Metadata:
runCount
number of times run
was invoked (automatically or manually)startedAt
when the last run
was invokedfinishedAt
when the last promise was fulfilled or rejectedThis API deviates quite a bit from React Async. Notably:
promiseFn
and deferFn
are combined into fn
promise
is dropped as an option. You can just pass () => promise
instead.A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.