react-client-async
Advanced tools
Comparing version 1.0.9 to 1.1.0
export { default as Async, $signal, type AsyncFC, type State, type WaitingFC, type FallbackFC, } from './libs/components/Async'; | ||
export { default as useAsync, $abortedByRerender, $abortedByUser, type UseAsyncFn, type UseAsyncOptions, } from './libs/hooks/useAsync'; | ||
export { default as useAsync, $abortedByRerender, $abortedByStop, type UseAsyncFn, type UseAsyncOptions, } from './libs/hooks/useAsync'; |
export { default as Async, $signal, } from './libs/components/Async'; | ||
export { default as useAsync, $abortedByRerender, $abortedByUser, } from './libs/hooks/useAsync'; | ||
export { default as useAsync, $abortedByRerender, $abortedByStop, } from './libs/hooks/useAsync'; |
@@ -43,3 +43,3 @@ import { type RefObject } from 'react'; | ||
*/ | ||
export declare const $abortedByUser: unique symbol; | ||
export declare const $abortedByStop: unique symbol; | ||
/** | ||
@@ -46,0 +46,0 @@ * Return type of the useAsync hook. |
@@ -10,3 +10,3 @@ import { useCallback, useRef, useState } from 'react'; | ||
*/ | ||
export const $abortedByUser = Symbol('Aborted By User'); | ||
export const $abortedByStop = Symbol('Aborted By Stop'); | ||
/** | ||
@@ -58,3 +58,3 @@ * The useAsync hook allows you to run an async function with options. | ||
const abortCtl = abortCtlRef.current; | ||
abortCtl?.abort($abortedByUser); | ||
abortCtl?.abort($abortedByStop); | ||
}, []); | ||
@@ -61,0 +61,0 @@ // Check if no need to rerun the async function. |
{ | ||
"name": "react-client-async", | ||
"version": "1.0.9", | ||
"version": "1.1.0", | ||
"main": "dist/lib.js", | ||
@@ -5,0 +5,0 @@ "module": "dist/lib.js", |
@@ -44,12 +44,11 @@ # ⚛️⏳ React Async for Client | ||
async ({ [$signal]: signal, n }) => | ||
n <= 0 ? ( | ||
<> {/* break the recursion */} | ||
<div>0</div> | ||
</> | ||
) : ( | ||
<> {/* delay and recursion */} | ||
{await delayWithSignal(99, signal)} | ||
(n <= 0) ? | ||
( // break the recursion | ||
<>{n}</> | ||
) : | ||
( // delay and recursion | ||
<>{await delayWithSignal(99, signal)} | ||
{n}<Async $fc={Rec} n={n - 1} />{n} | ||
</> | ||
), | ||
) | ||
); | ||
@@ -61,3 +60,3 @@ ``` | ||
- ⏳ `useAsyncIterable` hook | ||
- ⏳ `Iterable async` component | ||
- ⏳ `AsyncIterable` component | ||
@@ -87,7 +86,7 @@ ```tsx | ||
- Run demo: `bun dev` | ||
- Build demo: `bun run build:app` | ||
- Build package: `bun run build:lib` | ||
- Build demo: `bun build:app` | ||
- Build package: `bun build:lib` | ||
### Deploy | ||
- Deploy demo to github pages: `bun run deploy` | ||
- Publish the package to npm: `bun publish` | ||
- Deploy demo to github pages: `bun build:app:deploy` | ||
- Publish this package to npm: `bun build:lib:publish` |
16574
89