evented-react

0.0.2 • Public • Published

evented-react

To handle code with side-effects outside of your components, yo!

Example:

You can emit events from components like this!

import { EventSource } from 'evented-react'
 
@EventSource('authentication:authenticate')
export default class TheThing extends Component {
  render(props) {
    return (
      <button onClick={props.emit.authenticate()}>
        CLICK THE THING
      </button>
    )
  }
}

...but only if you wrapped it in something like this:

import { EventProvider } from 'evented-react'
import TheThing from './your-components/TheThing'
 
// You should probably put this somewhere more organized! <3
const eventMap = {
  'authentication:authenticate': console.log,
}
 
<EventProvider eventMap={eventMap}>
  <TheThing />
</EventProvider>

TODO:

[ ]: Actual documentation [ ]: Build it somehow [ ]: Create practical example

/evented-react/

    Package Sidebar

    Install

    npm i evented-react

    Weekly Downloads

    3

    Version

    0.0.2

    License

    MIT

    Last publish

    Collaborators

    • monokrome