@@ -9,17 +9,17 @@ import { RouterService } from "./router-service";
9
9
*/
10
10
export class RouterDispatcherService {
11
11
/**
12
- * Current store
12
+ * Current Vue instance
13
13
*/
14
- public store : any ;
14
+ public vm : any ;
15
15
16
16
/**
17
17
* Constructor for the RouterDispatcherService
18
18
*
19
- * @param {store } store The app store
19
+ * @param {Vue } vm Vue Instance
20
20
*/
21
- public constructor ( store : any ) {
22
- this . store = store ;
21
+ public constructor ( vm : any ) {
22
+ this . vm = vm ;
23
23
}
24
24
25
25
/**
@@ -29,7 +29,13 @@ export class RouterDispatcherService {
29
29
* @returns {boolean } If has finished dispatch or not
30
30
*/
31
31
public dispatchFromMeta ( meta : any ) : boolean {
32
- if ( ! meta || ! this . store ) {
32
+ if ( ! meta || ! this . vm ) {
33
+ return false ;
34
+ }
35
+
36
+ if ( ! this . vm . $store ) {
37
+ console . error ( 'META DISPATCHER' , 'Store not found' ) ;
38
+
33
39
return false ;
34
40
}
35
41
@@ -48,22 +54,22 @@ export class RouterDispatcherService {
48
54
* @returns {Promise } Dispatched action result
49
55
*/
50
56
public dispatch ( type : string , payload : unknown ) : Promise < void > {
51
- return this . store . dispatch ( type , payload ) ;
57
+ return this . vm . $ store. dispatch ( type , payload ) ;
52
58
}
53
59
}
54
60
55
61
/**
56
62
* Registers generic action dispatcher
57
63
*
58
- * @param {RouterService } router Vue-Router compatible class
59
- * @param {* } store Vuex Store Instance, or any other store that has a dispatch method exposed, with a type as 1st arg and payload as 2nd
64
+ * @param {RouterService } router Vue-Router compatible class
65
+ * @param {* } vm Vue Instance
60
66
* @returns {void }
61
67
*/
62
68
export const registerActionDispatcher = (
63
69
router : RouterService ,
64
- store : any
70
+ vm : any
65
71
) : void => {
66
- const dispatcherService = new RouterDispatcherService ( store ) ;
72
+ const dispatcherService = new RouterDispatcherService ( vm ) ;
67
73
68
74
router . beforeResolve ( ( to : Route , _from : Route , _next : NextContext ) => {
69
75
const route = router . getRoute ( to ) ;
0 commit comments