Package Exports
- react-use-eventbus-z
- react-use-eventbus-z/build/index.esm.js
- react-use-eventbus-z/build/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-use-eventbus-z) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Description
- Wrapper event bus: eventbus-z
- busClient: use with SSR
Usage
Install the package
npm install --save react-use-eventbus-z
Import the module in the place you want to use:
import { useEventBusOn, WrapEventBus } from 'react-use-eventbus-z';
Snippet
import { useEventBusOn, WrapEventBus } from 'react-use-eventbus-z';
const App = () => {
useEventBusOn('NAME', (abc, def) => {
alert('abcd');
})
return <Child />;
}
const Child = () => {
return <button onClick={() => WrapEventBus.sendEvent('NAME', 'abc', 1234)}>Abcd</button>
}
import { useEventBusOn, WrapEventBus } from 'react-use-eventbus-z';
const App = () => {
useEventBusOn('NAME', (resolve, reject, params) => {
// fetch api
resolve();
// reject();
alert(def);
})
return <Child />;
}
const Child = () => {
return <button
onClick={async () => {
const results = await WrapEventBus.sendAsyncEvent('NAME', params);
}}
>Abcd</button>
}
Events
See eventbus-z
RUN
License
MIT