diff --git a/README.md b/README.md index b5dad14..95dafda 100644 --- a/README.md +++ b/README.md @@ -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('只触发一次事件') +}) +``` diff --git a/package.json b/package.json index cb7f94f..b8a80fb 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "event-proxy", + "name": "@systemlight/event-proxy", "version": "1.0.0", "scripts": { "lint:prettier": "prettier src/ -w",