Segmented async operations to abort.
npm install segmented
import {segment} from 'segmented';
const segmented = segment(() => fetch('https://example.com'))
.then(response => response.json())
.then(console.log);
segmented.abort();
The segmented
object returned is also an callable equivalent to abort()
method:
import {segment} from 'segmented';
useEffect(
() =>
segment(() => fetch('https://example.com'))
.then(response => response.json())
.then(console.log),
[],
);
MIT License.