Skip to content

Instantly share code, notes, and snippets.

View sskyy's full-sized avatar
💭
Welcome to join Interaqt.

Zhenyu Hou sskyy

💭
Welcome to join Interaqt.
View GitHub Profile
function isNumber(l) {
return /^[0-9]$/.test(l)
}
function isSpace(l) {
return l === ' '
}
function isDot(l) {
return l === '.'

实现一个事件总线,要求满足一下特性:

  1. 简单的回调注册和事件触发。
// 注册
bus.on('event', function listener1(arg1, arg2) { ... } )
// 触发
bus.trigger('event', arg1, arg2)
  1. 同一事件下,回调可以指定顺序。要求有检测错误的能力。