# use-eventmit

> A simple event emitter hooks using [eventmit](https://github.com/azu/eventmit)

Latest version **1.0.3** (published 2020-06-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install use-eventmit
pnpm add use-eventmit
yarn add use-eventmit
bun add use-eventmit
```

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2020-06-02 |
| First published | 2020-06-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 8.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | steelydylan |
| Maintainers | steelydylan |

## Links

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

## Dependencies (1)

- [eventmit](https://npm.io/package/eventmit.md) ^1.0.2

## Recent versions

- 1.0.3 (latest) — 2020-06-02
- 1.0.2 — 2020-06-02
- 1.0.1 — 2020-06-01
- 1.0.0 — 2020-06-01

## README

# use-eventmit

A simple event emitter hooks using [eventmit](https://github.com/azu/eventmit)

## install

```sh
$ npm install use-eventmit --save
```

## usage

```tsx
import * as React from 'react'
import { useEmitter, useSubscriber } from 'use-eventmit'
import { render } from 'react-dom'

const Child = () => {
  const [count, setCount] = React.useState(0)
  useSubscriber<string>((event) => {
    setCount(count => count + 1)
  })
  return (<div>child {count} </div>)
}

const Parent = () => {
  const [emit, Provider] = useEmitter<string>()
  
  return (<Provider>
    <button onClick={() => {
      emit('hoge')
    }}>Emit!!</button>
    <Child />
  </Provider>)
}

render(<Parent />
, document.getElementById('main'))
```

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