Skip to content

Commit 17e234e

Browse files
committed
fix(events): teach until how to handle promises
1 parent 24bdcfc commit 17e234e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/utils/eventEmitter.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,10 @@ export default function eventEmitter() {
134134
until(event, fn) {
135135
if (typeof fn !== 'function') return this;
136136
function wrapper(...args) {
137-
if (fn(...args)) {
137+
const ret = fn(...args);
138+
if (ret instanceof Promise) {
139+
ret.then((val) => val && off(event, wrapper));
140+
} else if (ret) {
138141
off(event, wrapper);
139142
}
140143
}

0 commit comments

Comments
 (0)