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