0.0.8 • Published 6 years ago

deventh v0.0.8

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

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

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

Dependencies

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago