Skip to content

Commit

Permalink
feat(components): create useStore composable (#1401)
Browse files Browse the repository at this point in the history
  • Loading branch information
lauramargar authored Feb 1, 2024
1 parent 7784302 commit b4e42b9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/x-components/src/composables/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export * from './create-use-device.composable';
export * from './use-$x';
export * from './use-register-x-module';
export * from './use-on-display';
export * from './use-store';
13 changes: 13 additions & 0 deletions packages/x-components/src/composables/use-store.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { getCurrentInstance } from 'vue';
import { Store } from 'vuex';

/**
* Function which returns the `$store` object from the current component instance.
*
* @returns The `$store` object from the current component instance.
*
* @public
*/
export function useStore(): Store<any> {
return (getCurrentInstance()?.proxy as { $store: Store<any> }).$store;
}

0 comments on commit b4e42b9

Please sign in to comment.