# @r3dev/lets-wait

> This simple API allows you to manually control named tasks/processes as promises, in an imperative manner.

Latest version **0.3.0** (published 2022-12-28) · ISC license · 0 weekly downloads

## Install

```sh
npm install @r3dev/lets-wait
pnpm add @r3dev/lets-wait
yarn add @r3dev/lets-wait
bun add @r3dev/lets-wait
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2022-12-28 |
| First published | 2022-12-28 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Yuri Bento |
| Maintainers | r3dev |
| Keywords | api, promise, await, tasks, processes, simple, imperative |

## Links

- npm: https://www.npmjs.com/package/@r3dev/lets-wait
- npm.io page: https://npm.io/package/@r3dev/lets-wait

## Alternatives

- [promise-throttle](https://npm.io/package/promise-throttle.md) — 44.2K weekly downloads
- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads

## Recent versions

- 0.3.0 (latest) — 2022-12-28
- 0.2.0 — 2022-12-28
- 0.1.0 — 2022-12-28

## README

###### This simple API allows you to manually control named tasks/processes as promises, in an imperative manner.

###### Example with React:

```js
function SomeComponent() {
  const { login, user } = useLogin();
  const [loading, setLoading] = useState(false);

  async function loginWithData() {
    lets.start("login.user.data");
    setLoading(true);
    await login(); // this login function doesn't fetch all component required data
    await lets.waitFor("login.user.data");
    setLoading(false);
  }

  useEffect(() => {
    if (user.data) {
      lets.finish("login.user.data");
    }
  }, [user]);

  //...
}
```
`This is just a random example and not a good example of best practices.`

#### Api

- lets.start(processID: string) - Start or restart a named process
- lets.waitFor(processID: string): Promise<any> - Returns a promise of a previously started process (instantly rejected if the process does not exist).
- lets.finish(processID: string): Boolean - Terminates a previously started process and resolve its promise (returns true if the process was found and terminated).

---
_Source: https://npm.io/package/@r3dev/lets-wait · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
