Skip to content

Commit

Permalink
feat: 增加one之后调用中间件
Browse files Browse the repository at this point in the history
  • Loading branch information
SystemLight committed Jul 13, 2022
1 parent 5e86492 commit 7be9f42
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,12 @@ EventProxy.prototype.on = function (callback) {
* @param callback
*/
EventProxy.prototype.one = function (callback) {
this.on(callback)
this.use(() => this.off())
this
.on(callback)
.use((e, next) => {
this.off()
next()
})
}

/**
Expand Down

0 comments on commit 7be9f42

Please sign in to comment.