Open zenHeart opened 4 years ago
Oh thanks for the report. Good catch. I think this is not intended, but might be hard to solve...
When registering the same module twice, we can't be sure if it's really the same module. An user might be registering different module with the same name.
Either way, should we call unregisterModule
before registering any module if it has the same name...? I think that might be what people wants.
when a module with the same name is registered repeatedly, there is an warning on the console:
And maybe it's a deliberate design, please check the doc: https://vuex.vuejs.org/guide/modules.html#namespacing
By default, actions and mutations are still registered under the global namespace - this allows multiple modules to react to the same action/mutation type.
so if you register a module twice, then mutatation
will respond twice correspondingly.
Version
3.5.1
Reproduction link
https://codepen.io/zenheart/pen/oNLbvJO
Steps to reproduce
see demo https://codepen.io/zenheart/pen/oNLbvJO
What is expected?
Why registerModule call the same path multi times, will replace old path, but push handle to
_mutations
, see demo https://codepen.io/zenheart/pen/oNLbvJOWhat is actually happening?
this will make add run twice. It's weird, I think we should replace all, this feature is expected, why?