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

docs: combine nuxt-composition-api and nuxt-typed-vue #113

Closed
regenrek opened this issue May 30, 2020 · 5 comments
Closed

docs: combine nuxt-composition-api and nuxt-typed-vue #113

regenrek opened this issue May 30, 2020 · 5 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@regenrek
Copy link

📚 Is your documentation request related to a problem? Please describe.

Hi does nuxt-typed-vuex and nuxt-composition-api work together out of the box.
Do you have any example repo where these two are used together?

Thanks in advance!

@regenrek regenrek added the documentation Improvements or additions to documentation label May 30, 2020
@danielroe
Copy link
Owner

Yes, good idea. I'll add some composables to this package. Any preferences on the way you would like to use it?

@regenrek
Copy link
Author

Hi,

yeah, it would be interesting how you would use (memory) state management in combination with for example graphql to read/write data. For example using nuxt-typed-vuex to manage todos state and use nuxt-composition-api composables for crud operations.

Kind of this here (rooms - state) and here (rooms - graphql)

@nimarion
Copy link

nimarion commented Feb 7, 2021

Any updates?

@danielroe
Copy link
Owner

With the next release of @nuxtjs/composition-api this will be as simple as creating your own useAccessor function.

import { wrapProperty } from '@nuxtjs/composition-api'
export const useAccessor = wrapProperty('$accessor', false)

// You can now get a fully typed accessor within `setup()`

export default defineComponent({
  setup() {
    const accessor = useAccessor()
    // You can now access a fully typed store accessor in your component
  },
})

@P4sca1
Copy link

P4sca1 commented Apr 2, 2021

@danielroe In how far is this different from const { $accessor } = useContext()?
Also I noticed that the state is not reactive in a way. You have to manually wrap each attribute that you want to use in a computed property, e.g.:

const { $accessor } = useContext()
const authenticatedUser = computed(() => $accessor.authenticatedUser )
    
return {
    authenticatedUser
}

Without the computed, resetting authenticatedUser to another value wont update the component.
Is this a limitation of Vue 2 and can this process somehow be simplified, because wrapping everything with a computed is quite verbose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

4 participants