Cannot handle Promise Like type in $onAction callback #3030
Unanswered
Hermes-Axe
asked this question in
Help and Questions
Replies: 1 comment 3 replies
-
I don't understand the question (or idea suggestion): in after, res is the resolved value to not have to deal with promises |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
when I use $onAction to add after action callback, which is using promise like, it doesn‘t work

Example:
App.vue
useTestStore.js

maybe we can determine whether it is a Promise Like type,like use tool function
function isPromiseLike (val) { return val && typeof val.then === 'function' }
to replace the following judgement
// if (isPromiseLike(ret)) if (ret instanceof Promise) { return ret .then((value) => { triggerSubscriptions(afterCallbackSet, value) return value }) .catch((error) => { triggerSubscriptions(onErrorCallbackSet, error) return Promise.reject(error) }) }
Beta Was this translation helpful? Give feedback.
All reactions