npm

@for-fun/event-emitter
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Build Status Coverage Status install size

event-emitter

Simple event emitter.

Install

npm i @for-fun/event-emitter

Usage

import * as React from 'react';
import {create, on, emit} from '@for-fun/event-emitter';

const emitter = create();

export default function() {
  const [message, setMessage] = React.useState('');
  React.useEffect(() => on(emitter, 'message', setMessage));

  return <div>
    <p>{message}</p>
    <button onClick={() => emit(emitter, 'message', 'hello')}>Click Me</button>
  </div>;
}

Compatibility Note

This lib support these browsers or devices with these methods or APIs pollyfilled.

Workflow

# develop
npm start

# build
npm run build

# test
npm test

# commit changes
npm run commit

# publish
npm publish

Readme

Keywords

Package Sidebar

Install

npm i @for-fun/event-emitter

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

28.4 kB

Total Files

11

Last publish

Collaborators

  • wmzy