# react-async-decorator

> Decorators for support async react rendering

Latest version **0.2.8** (published 2019-08-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-async-decorator
pnpm add react-async-decorator
yarn add react-async-decorator
bun add react-async-decorator
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.8 |
| Published | 2019-08-13 |
| First published | 2018-03-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 80.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Efremov Alexey |
| Maintainers | lexich |

## Links

- npm: https://www.npmjs.com/package/react-async-decorator
- Repository: https://github.com/lexich/react-async-decorator
- Homepage: https://github.com/lexich/react-async-decorator#readme
- Issues: https://github.com/lexich/react-async-decorator/issues
- npm.io page: https://npm.io/package/react-async-decorator

## Recent versions

- 0.2.8 (latest) — 2019-08-13
- 0.2.7 — 2019-08-13
- 0.2.6 — 2019-01-23
- 0.2.5 — 2018-11-09
- 0.2.4 — 2018-11-08
- 0.2.3 — 2018-11-08
- 0.2.2 — 2018-11-08
- 0.2.1 — 2018-09-14
- 0.2.0 — 2018-09-04
- 0.1.9 — 2018-07-31
- 0.1.8 — 2018-07-31
- 0.1.7 — 2018-07-30
- 0.1.6 — 2018-07-23
- 0.1.5 — 2018-07-18
- 0.1.4 — 2018-06-28
- … 11 more at https://npm.io/package/react-async-decorator/versions

## README

# react-async-decorator

New way to organize your asynchronous flow in react applications. inspired by [Dan Abramov: Beyond React 16](https://www.youtube.com/watch?v=nLF0n9SACd4).

[![Build Status](https://travis-ci.org/lexich/react-async-decorator.svg?branch=master)](https://travis-ci.org/lexich/react-async-decorator)

## Getting Started

### Installing

```sh
npm install react-async-decorator
```

If you prefer [yarn](https://yarnpkg.com)

```sh
yarn react-async-decorator
```

### Simple example

```js
import { asyncClass, initFetchers } from 'react-async-decorator';
const config = initFetchers();
const fetcher = config.createFetcher(() => fetch('/data.json'));

// If you don't want to use decorators, it should be replaced next syntax
// const WrapTest = asyncClass(fetcher)(Test);
@asyncClass(fetcher)
class Test extends React.Component {
    render() {
        const data = fetcher.get();
        // This content will be rendered after success response of fetch request
        return <div>{data}</div>;
    }
    renderLoader() {
        // This content will be rendered while fetch request in progress
        return <div>Loading</div>;
    }
    renderError(err) {
        // This content will be rendered after fail response of fetch request
        return <div>{err.message}</div>;
    }
}
```

## Documentation

- [index.md](docs/index.md)
- [examples.md](docs/examples.md)

## Running the tests

All unit tests are in `__tests__` folder. They are written with [jest](https://jestjs.io/).

```sh
npm test
```

## Contributing

We are happy any contributions. Please be aware of all unit-tests and linters passed.

## Versioning

We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/lexich/react-async-decorator/tags). Thanks for [standard-version](https://github.com/conventional-changelog/standard-version) for automation.

## Authors

* **Efremov Alexey** - [lexich](https://github.com/lexich)

## License

This project is licensed under the MIT License - see the [LICENSE.md](LICENSE) file for details

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