react-mitt-wrapper
v1.0.4
Published
React provider and hooks for using Mitt events library
Readme
react-mitt-wrapper
React provder and hooks for using Mitt events library
Install
npm install --save react-mitt-wrapperUsage
import React, {Component} from 'react'
import {MittProvider, useMittOn} from 'react-mitt-wrapper'
export function App() {
return <MittProvider>
<Foo />
</MittProvider>
}
export function Foo() {
useMittOn('myEvent', (eventData) => {
console.log(eventData)
})
return <></>
}Hooks
useMittOn(eventType, callback) – uses for subscribing to the event
useMittOff(eventType, callback) – uses for unsubscribing from the event
useMittEmit() – uses for emitting value to the event. Returns emit function for it
useMittClear() – uses for clearing all events
License
MIT © dkildar
