Cannot handle Promise Like type in $onAction callback #3031
Closed
Hermes-Axe
started this conversation in
Ideas
Replies: 0 comments
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