@ekz/async-data
v1.0.2
Published
Async data wrapper for promises
Readme
@ekz/async-data
Type-safe async state for promises.
Documentation: https://docs.ekz.io/async-data/
Install
npm install @ekz/async-data @ekz/optionQuick example
import { Empty, Ready, observePromise } from '@ekz/async-data';
let data = Empty<User>();
data = data.pending();
data = Ready({ id: 1, name: 'Ada' });
const label = data.match(
{
Ready: (user) => user.name,
Pending: () => 'Loading…',
},
() => '—',
);See the docs for states, promise observation, and extractors.
