Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: create useStore composable #1401

Merged
merged 1 commit into from
Feb 1, 2024

Conversation

lauramargar
Copy link
Contributor

@lauramargar lauramargar commented Jan 31, 2024

EMP-3452

Pull request template

Vuex 3 does not have a store composable and we need a way to get access to the store in the components using the composition API. We have created a useStore composable.

Motivation and context

  • Dependencies. If any, specify:
  • Open issue. If applicable, link: EMP-3452

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that causes existing functionality to not work as expected)
  • Change requires a documentation update

What is the destination branch of this PR?

  • Main
  • Other. Specify:

How has this been tested?

You can use the useStore composable in an existing component with the defineComponent syntax OR you can create a test component and access there to the useStore composable.

Example of test component:

<template>
  <div>
    <span>{{ test }}</span>
  </div>
</template>

<script lang="ts">
  import { defineComponent } from 'vue';
  import { useStore } from '../composables';
  export default defineComponent({
    setup() {
      const $store = useStore();

      const test = $store.state.x.historyQueries.historyQueries;
      return {
        test
      };
    }
  });
</script>

Checklist:

  • My code follows the style guidelines of this project.
  • I have performed a self-review on my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.

@lauramargar lauramargar requested a review from a team as a code owner January 31, 2024 10:04
@CachedaCodes CachedaCodes merged commit b4e42b9 into main Feb 1, 2024
4 checks passed
@CachedaCodes CachedaCodes deleted the feature/EMP-3452-create-a-use-store-composable branch February 1, 2024 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants