-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add { root: true }
option support to dispatch.
#6
Conversation
Thank you for your PR! |
Anytime! Using a dispatch like As a matter of fact, I'm using an I was just wondering if the actual implementation can take advantage of the same escape-from-isolation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better if we also have root level commit? 🙂
src/register.ts
Outdated
if (typeof type === 'object') { | ||
type = type.type | ||
payload = type | ||
} | ||
return dispatch(localKey(type, moduleName), payload) | ||
|
||
if (!options || !options.root) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also unify the options
like commit method does? In current implementation, the options object always be 3rd argument even if the users call object style dispatch.
test/register.ts
Outdated
actions: { | ||
foo ({ dispatch, rootGetters }: any) { | ||
dispatch('rootAction', 'bar', { root: true }).then(() => { | ||
assert(rootGetters.propertyGetter() === 'bar') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this test is finished before executing this line. We need to use mocha's done
callback here.
- Update localDispatch to support options. - Implement root option on both commit and dispatch. - Update README.md file (sentence specifying the root option).
Absolutely! |
Looks nice, thank you! |
You're welcome! Thank you for your time. |
I've encountered a couple of cases where dispatching in the global namespace might become in handy.
This PR provide a way to dispatch on the global namespace by providing a
{ root: true }
option as the third argument todispatch
.