deventh
v0.0.8
Published
Declarative (Synthetic) Event Handler
Downloads
1
Readme
deventh
Declarative (Synthetic) Event Handler
It's a tiny library with handler of events.
It uses fluent interface and is inspired by the implementation of event handling in Vue.
Recommendations
Yet it's not ready for production
Examples
import React from 'react'
import { connect } from 'react-redux'
import deventh from 'deventh'
import photo from './photo.jpg'
@connect()
export default function Photo({ id, dispatch }) {
const openPhoto = () => dispatch({ type: 'open_photo', id })
const likePhoto = () => dispatch({ type: 'like_photo', id })
const handleClick = event => deventh(event)
.debounce({ ms: 300 })
.handle((_, n) => switch (n) {
if (n === 1) {
openPhoto()
} else if (n === 2) {
likePhoto()
}
})
return (
<img src={photo} onClick={handleClick} />
)
}
Issues
- [x] Add declarative properties
- [x] Event interuptions
- [x] Behavioural flags
- [ ] Add event keys
- [x] Keyboard
- [ ] Mouse
- [ ] Touch
Dependencies
- schematic-fluent to organise fluent interface