# @byteclaw/use-event-emitter

> React hooks and components for construction of simple event emitters

Latest version **1.0.2** (published 2021-05-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install @byteclaw/use-event-emitter
pnpm add @byteclaw/use-event-emitter
yarn add @byteclaw/use-event-emitter
bun add @byteclaw/use-event-emitter
```

## Health

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

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

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2021-05-24 |
| First published | 2019-11-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 15.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 12 |
| Maintainers | jurajhrib, michalkvasnicak |
| Keywords | react, hooks, question, dialog, confirm, alert, notification, prompt |

## Links

- npm: https://www.npmjs.com/package/@byteclaw/use-event-emitter
- Repository: https://github.com/byteclaw/hooks
- Homepage: https://github.com/byteclaw/hooks/tree/master/packages/use-event-emitter#readme
- Issues: https://github.com/byteclaw/hooks/issues
- npm.io page: https://npm.io/package/@byteclaw/use-event-emitter

## 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.2 (latest) — 2021-05-24
- 1.0.1 — 2020-12-28
- 1.0.0 — 2019-11-15

## README

# @Byteclaw/use-event-emitter

[React](https://github.com/facebook/react) hooks and components for construction of simple event emitters.

## Installation

```console
npm install @byteclaw/use-event-emitter
yarn add @byteclaw/use-event-emitter
```

## Usage

Here is a quick example how to use these hooks.

```jsx
import {
  EventEmitterContext,
  useEventEmitterInstance,
  useEventEmitter,
} from '@byteclaw/use-event-emitter';
import React, { useEffect } from 'react';

function Comp() {
  // returns the event emitter from the context
  const eventEmitter = useEventEmitter();

  useEffect(() => {
    const unsubscribe = eventEmitter.on('test', (...args) => console.log(args));

    return () => unsubscribe();
  }, []);
}

function App({ children }) {
  // returns the new instance of event emitter
  const eventEmitter = useEventEmitterInstance();

  return (
    <EventEmitterContext.Provider value={eventEmitter}>
      <Comp1 />
    </EventEmitterContext.Provider>
  );
}
```

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