# unstated-suspense

> Suspend/unsuspend updates propagation from your containers.

Latest version **1.0.3** (published 2018-12-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install unstated-suspense
pnpm add unstated-suspense
yarn add unstated-suspense
bun add unstated-suspense
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2018-12-10 |
| First published | 2018-09-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 13.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Fabio Spampinato |
| Maintainers | fabiospampinato |
| Keywords | react, unstated, hoc, suspend, performance |

## Links

- npm: https://www.npmjs.com/package/unstated-suspense
- Repository: https://github.com/fabiospampinato/unstated-suspense
- Homepage: https://github.com/fabiospampinato/unstated-suspense#readme
- Issues: https://github.com/fabiospampinato/unstated-suspense/issues
- npm.io page: https://npm.io/package/unstated-suspense

## Dependencies (1)

- [@types/node](https://npm.io/package/@types/node.md) ^10.12.8

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.3 (latest) — 2018-12-10
- 1.0.2 — 2018-12-03
- 1.0.1 — 2018-10-02
- 1.0.0 — 2018-09-25

## README

# Unstated Suspense

Suspend/unsuspend updates propagation from your containers.

It allows you to update the state multiple times while still triggering only one update of the components.

## Install

```sh
npm install --save unstated-suspense
```

## Usage

```ts
import {Container} from 'unstated-suspense';

class App extends Container {
  state = { foo: 1, bar: 2 };
  update () {
    this.suspend (); // After calling `suspend` the components won't be notified of any state update
    this.setFoo ( 11 ); // This will change the state, but it won't trigger an update of the components
    this.setBar ( 12 ); // This will change the state, but it won't trigger an update of the components
    this.unsuspend (); // Now updates are no longer suspended. If the state has been updated it will notify the components, just once (instead of twice in this particular case)
  }
  setFoo ( foo ) {
    this.setState ({ foo });
  }
  setBar ( bar ) {
    this.setState ({ bar });
  }
}
```

**Note**: If you call `suspend` N times you should call `unsuspend` N time also to resume updates propagation.


## Related

- **[unstated-with-containers](https://github.com/fabiospampinato/unstated-with-containers)**: Higher-Order Component for subscribing to containers.
- **[unstated-connect2](https://github.com/fabiospampinato/unstated-connect2)**: Connect containers to components, without sacrificing performance.
- **[unstated-hmr](https://github.com/fabiospampinato/unstated-hmr)**: Preserve containers' states across Hot-Module-Replacements.
- **[unstated-compose](https://github.com/fabiospampinato/unstated-compose)**: Compose multiple containers into one.
- **[unstated-compose-suspense](https://github.com/fabiospampinato/unstated-compose-suspense)**: Add suspend/unsuspend support to `unstated-compose`.
- **[unstated-compose-suspense-middleware](https://github.com/fabiospampinato/unstated-compose-suspense-middleware)**: Add middlewares support to `unstated-compose-suspense`.
- **[unstated-suspense-autosuspend](https://github.com/fabiospampinato/unstated-suspense-autosuspend)**: Automatically use unstated-suspense on all your container's API methods.
- **[unstated-suspense-middleware](https://github.com/fabiospampinato/unstated-suspense-middleware)**: Add middlewares support to `unstated-suspense`.

## License

MIT © Fabio Spampinato

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