Skip to content

Commit

Permalink
feat: create useStore composable
Browse files Browse the repository at this point in the history
  • Loading branch information
lauramargar committed Jan 31, 2024
1 parent 850a741 commit 481c59a
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 481c59a

Please sign in to comment.