# rmo

> Encapsulating model with react hooks.

Latest version **1.0.0** (published 2020-11-08) · ISC license · 0 weekly downloads

## Install

```sh
npm install rmo
pnpm add rmo
yarn add rmo
bun add rmo
```

## 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.0 |
| Published | 2020-11-08 |
| First published | 2020-11-08 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 9.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | wchen |
| Maintainers | shanevv |

## Links

- npm: https://www.npmjs.com/package/rmo
- npm.io page: https://npm.io/package/rmo

## Recent versions

- 1.0.0 (latest) — 2020-11-08

## README

# Rmo

Rmo helps you encapsulate models with react hooks.

## Install

```shell
yarn add rmo
# or use npm
npm i rmo
```

## Create a model

~~~tsx
import rmo from 'rmo'

// create a view model by react hooks
const useModel = rmo(() => {
  const [a, setA] = useState('a')
  const [b, setB] = useState('b')

  return { a, b, setA, setB }
})

// use model in Parent
function Parent() {
  const model = useModel()

  return (
    <>
      <div>{ model.a }</div>
      <button onClick={setB}>setB</button>
    </>
  )
}

// use model anywhere...
function Child() {
  const model = useModel()

  return (
    <>
      <div>{ model.b }</div>
      <button onClick={setA}>setA</button>
    </>
  )
}
~~~

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