@@ -9,17 +9,17 @@ import { RouterService } from "./router-service";
99 */
1010export class RouterDispatcherService {
1111 /**
12- * Current store
12+ * Current Vue instance
1313 */
14- public store : any ;
14+ public vm : any ;
1515
1616 /**
1717 * Constructor for the RouterDispatcherService
1818 *
19- * @param {store } store The app store
19+ * @param {Vue } vm Vue Instance
2020 */
21- public constructor ( store : any ) {
22- this . store = store ;
21+ public constructor ( vm : any ) {
22+ this . vm = vm ;
2323 }
2424
2525 /**
@@ -29,7 +29,13 @@ export class RouterDispatcherService {
2929 * @returns {boolean } If has finished dispatch or not
3030 */
3131 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+ 3339 return false ;
3440 }
3541
@@ -48,22 +54,22 @@ export class RouterDispatcherService {
4854 * @returns {Promise } Dispatched action result
4955 */
5056 public dispatch ( type : string , payload : unknown ) : Promise < void > {
51- return this . store . dispatch ( type , payload ) ;
57+ return this . vm . $ store. dispatch ( type , payload ) ;
5258 }
5359}
5460
5561/**
5662 * Registers generic action dispatcher
5763 *
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
6066 * @returns {void }
6167 */
6268export const registerActionDispatcher = (
6369 router : RouterService ,
64- store : any
70+ vm : any
6571) : void => {
66- const dispatcherService = new RouterDispatcherService ( store ) ;
72+ const dispatcherService = new RouterDispatcherService ( vm ) ;
6773
6874 router . beforeResolve ( ( to : Route , _from : Route , _next : NextContext ) => {
6975 const route = router . getRoute ( to ) ;
0 commit comments