Simple event emitter.
npm i @for-fun/event-emitter
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>;
}
This lib support these browsers or devices with these methods or APIs pollyfilled.
# develop
npm start
# build
npm run build
# test
npm test
# commit changes
npm run commit
# publish
npm publish