0.3.4 • Published 3 years ago

@uniczjc/event v0.3.4

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

@uniczjc/event

🌛事件处理

分为两部分

  • 原始事件处理(mitt)
  • 封装的事件组件(event)

Mitt

示例

import { MittEvent } from '@uniczjc/event'

const Mitt = new UEvent()

// 拦截器
Mitt.beforeEach(type, next) {
  console.log(type)
  next()
}

// 监控
Mitt.on('update', (ev) => {
  console.log(ev)
})

// 绑定
Mitt.emit('update', 'test')

// 解绑
Mitt.off('update')
// 解绑全部
Mitt.off()

// 销毁
Mitt.destroy()

方法

on(eventName, callback)
名称类型数据类型说明
eventName参数String/Symbol事件名称
listener参数Function回调函数

Event

import UEvent from '@uniczjc/event'
import { Swipe } from '@uniczjc/action' //  预设的手势action

const el = document.getElementById('ID')
const UV = new UEvent(el)
UV.use(Swipe, {name: 'swipe'})

// 监控
UV.on('swipe', (ev) => {
  console.log(ev)
})
UV.on('updateend', (ev) => {
})

// 获取事件信息
const uOption = UV.get('swipe')

// 修改事件状态
uOption.disabled = true // 禁用事件

方法

use(action, option)
名称类型数据类型说明
action参数Action需要注册的action
option参数Object插件配置

on(eventName, callback)

名称类型数据类型说明
eventName参数String事件名称
callback参数Funtion回调函数

get(eventName)

名称类型数据类型说明
eventName参数String事件名称
0.2.40

3 years ago

0.2.27

3 years ago

0.2.26

3 years ago

0.2.25

3 years ago

0.2.39

3 years ago

0.2.30

3 years ago

0.2.38

3 years ago

0.2.37

3 years ago

0.2.36

3 years ago

0.2.35

3 years ago

0.2.34

3 years ago

0.2.33

3 years ago

0.2.32

3 years ago

0.2.31

3 years ago

0.3.0

3 years ago

0.2.29

3 years ago

0.2.28

3 years ago

0.3.2

3 years ago

0.3.1

3 years ago

0.3.4

3 years ago

0.3.3

3 years ago

0.2.24

3 years ago

0.2.23

3 years ago

0.2.22

3 years ago

0.2.21

3 years ago

0.2.20

3 years ago

0.2.19

3 years ago

0.2.18

3 years ago

0.2.17

3 years ago

0.2.16

3 years ago

0.2.15

3 years ago

0.2.14

3 years ago

0.2.13

3 years ago

0.2.10

3 years ago

0.2.9

3 years ago

0.2.7

3 years ago

0.2.6

3 years ago

0.2.5

3 years ago

0.2.4

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago