Skip to content

Commit

Permalink
feat: 补充文档说明
Browse files Browse the repository at this point in the history
  • Loading branch information
SystemLight committed Jul 8, 2022
1 parent b30e267 commit 379c828
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
# event-proxy

> Event agent processing library.
### Usage

```javascript
eventProxy('click', '.selector').on(function (e) {
console.log('事件触发')
})

eventProxy('click', '.parent', '.selector').on(function (e) {
console.log('事件代理')
})

eventProxy('click', '.parent', '.selector').use(function (e, next) {
console.log('before middleware')
next()
}).on(function (e) {
console.log('中间件')
}).use(function (e, next) {
console.log('after middleware')
// 触发一次后关闭
this.off()
next()
})

eventProxy('click', '.parent', '.selector').one(function (e) {
console.log('只触发一次事件')
})
```
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "event-proxy",
"name": "@systemlight/event-proxy",
"version": "1.0.0",
"scripts": {
"lint:prettier": "prettier src/ -w",
Expand Down

0 comments on commit 379c828

Please sign in to comment.