deventh

0.0.8 • Public • Published

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 (=== 1) {
                    openPhoto()
                } else if (=== 2) {
                    likePhoto()
                }
            })
 
    return (
        <img src={photo} onClick={handleClick} />
    )
}

Issues

  • Add declarative properties
    • Event interuptions
    • Behavioural flags
  • Add event keys
    • Keyboard
    • Mouse
    • Touch

Dependencies

Readme

Keywords

Package Sidebar

Install

npm i deventh

Weekly Downloads

2

Version

0.0.8

License

MIT

Unpacked Size

159 kB

Total Files

12

Last publish

Collaborators

  • beraliv