Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/monokrome/evented-react
- Owner: monokrome
- License: mit
- Created: 2018-01-03T11:17:00.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-04-20T02:45:17.000Z (over 1 year ago)
- Last Synced: 2024-10-17T10:18:29.268Z (29 days ago)
- Language: JavaScript
- Size: 10.7 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.txt
- License: LICENSE
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