feat(runtime-core): emit now returns array of return values from all triggered handlers

close #635
This commit is contained in:
Evan You
2020-01-20 11:24:08 -05:00
parent aca2c2a81e
commit e81c8a32c7
4 changed files with 124 additions and 8 deletions

View File

@@ -74,7 +74,7 @@ export function callWithAsyncErrorHandling(
instance: ComponentInternalInstance | null,
type: ErrorTypes,
args?: unknown[]
) {
): any[] {
if (isFunction(fn)) {
const res = callWithErrorHandling(fn, instance, type, args)
if (res != null && !res._isVue && isPromise(res)) {
@@ -85,9 +85,11 @@ export function callWithAsyncErrorHandling(
return res
}
const values = []
for (let i = 0; i < fn.length; i++) {
callWithAsyncErrorHandling(fn[i], instance, type, args)
values.push(callWithAsyncErrorHandling(fn[i], instance, type, args))
}
return values
}
export function handleError(