react-emit-provider
Installing
npm install react-emit-provider
Usage
Provider
;;;; const ee = ;const emit = eeemit; ReactDOM;
Component Wiring
To get the emitter:
; const Component = props const emit = props; return <button onClick= >Button</button>;; Component;
To get a emitter of specific eventName
; const Component = props const clickedEmitter = props; return <button onClick=clickedEmitter>Button</button>;; 'clicked'Component;
Or multiple:
; const Component = props const connectEmitter disconnectEmitter = props; return <div> <button onClick=connectEmitter>connect</button> <button onClick=disconnectEmitter>disconnect</button> </div> ;; 'connect' 'disconnect'Component;
Advanced Wiring
Advanced wiring can give you more control over the injected methods. It will also, by default, perform memoization to avoid generating multiple handlers.
; const Component = props const item handleSelect handleUnselect = props; return <div> <div>itemname</div> <button onClick=>select</button> <button onClick=>unselect</button> </div> ;; channel: { ; } { ; } Component;
Which would be dispatched as:
ee;
wireAdvanced()
handlers will also pass through arguments given
to the handler on invocation, as well as partially applied arguments
during handler construction.
const Component = <button =>Button</button> const Wired = ;