Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/monokrome/evented-react

To move side effects out of your component code
https://github.com/monokrome/evented-react

Last synced: 18 days ago
JSON representation

To move side effects out of your component code

Awesome Lists containing this project

README

        

## evented-react

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

## Example:

You can emit events from components like this!

```javascript
import { EventSource } from 'evented-react'

@EventSource('authentication:authenticate')
export default class TheThing extends Component {
render(props) {
return (

CLICK THE THING

)
}
}

```

...but only if your root component (or any parent, really) provides `EventProvider`:

```javascript
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,
}

ReactDOM.render((



), document.body.children[0])

```

## TODO:

- [ ] Actual documentation
- [ ] Build it somehow
- [ ] Create practical example
- [x] Eat ice cream