mirror of
https://github.com/MetinSeylan/Vue-Socket.io.git
synced 2025-04-16 15:21:28 +02:00
Modified event dispatch in the store
This commit is contained in:
parent
ee1e7ed1ee
commit
848dd8bd3e
2 changed files with 38 additions and 40 deletions
2
dist/vue-socketio.js
vendored
2
dist/vue-socketio.js
vendored
File diff suppressed because one or more lines are too long
|
@ -90,47 +90,45 @@ export default class EventEmitter{
|
|||
* @param args
|
||||
*/
|
||||
dispatchStore(event, args){
|
||||
|
||||
if(this.store && this.store._actions){
|
||||
|
||||
let prefixed_event = this.actionPrefix + event;
|
||||
|
||||
for (let key in this.store._actions) {
|
||||
|
||||
let action = key.split('/').pop();
|
||||
|
||||
if(action === prefixed_event) {
|
||||
|
||||
Logger.info(`Dispatching Action: ${key}, Data:`, args);
|
||||
|
||||
this.store.dispatch(key, args);
|
||||
|
||||
if(!this.store){
|
||||
return
|
||||
}
|
||||
|
||||
this.dispatchModule('', this.store._modules.root, event, args)
|
||||
}
|
||||
|
||||
if(this.mutationPrefix) {
|
||||
dispatchModule(path, mod, event, args){
|
||||
const action_prefixed_event = this.actionPrefix + event;
|
||||
|
||||
let prefixed_event = this.mutationPrefix + event;
|
||||
// If the action exists in the module dispatch it
|
||||
if (mod._rawModule.actions[action_prefixed_event]) {
|
||||
|
||||
for (let key in this.store._mutations) {
|
||||
const fullKey = path + action_prefixed_event
|
||||
|
||||
let mutation = key.split('/').pop();
|
||||
|
||||
if(mutation === prefixed_event) {
|
||||
|
||||
Logger.info(`Commiting Mutation: ${key}, Data:`, args);
|
||||
|
||||
this.store.commit(key, args);
|
||||
Logger.info(`Dispatching Action: ${fullKey}, Data:`, args);
|
||||
|
||||
this.store.dispatch(fullKey, args);
|
||||
}
|
||||
|
||||
}
|
||||
if(this.mutationPrefix){
|
||||
|
||||
const mutation_prefixed_event = this.mutationPrefix + event;
|
||||
|
||||
// If the mutation exists in the module commit it
|
||||
if (mod._rawModule.mutations[mutation_prefixed_event]) {
|
||||
|
||||
const fullKey = path + mutation_prefixed_event
|
||||
|
||||
Logger.info(`Commiting Mutation: ${fullKey}, Data:`, args);
|
||||
|
||||
this.store.commit(fullKey, args);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Call this method recursively on every submodules
|
||||
for (const submodule in mod._children) {
|
||||
this.dispatchModule(path + submodule + '/', mod._children[submodule], event, args)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue