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

using Multiple Namespaced Helpers in the same component #49

Open
uniquedj95 opened this issue Aug 30, 2021 · 5 comments
Open

using Multiple Namespaced Helpers in the same component #49

uniquedj95 opened this issue Aug 30, 2021 · 5 comments

Comments

@uniquedj95
Copy link

How can I use multiple namespaced helpers in a single component?

@davidmeirlevy
Copy link
Contributor

Use the namespaced helper twice.

@uniquedj95
Copy link
Author

will that not conflict each other. for instance,

const { useState} = createNamespacedHelper('moduleA')
const { useState} = createNamespacedHelper('moduleB')

so when I call useState() which one am I calling/invoking?

@davidmeirlevy
Copy link
Contributor

In JS you can choose between:

const { a as b } = getB()
const { a as x } = getX()

Or

const a = getB().a;
const b = getX().a;

Or

const mapperA = getMapper("a")
const mapperB = getMapper("b")
...
mappperA.useGetters(["a"])

Choose your favorite.

@nolde
Copy link
Contributor

nolde commented Dec 1, 2021

Would be nice to have "in-place" namespaces, similar to what happens with vuex mappers.

import { useGetters } from 'vuex-composition-helpers'

export default {
  setup() {
    const { one, two } = useGetters('my/long/name/space', ['one', 'two'])
    const { uno, dos } = useGetters('my/other/thing', ['uno', 'dos'])
    return { one, two, uno, dos }
  }
}

@davidmeirlevy
Copy link
Contributor

@nolde as you can see in the source code, the global functions are passing null as a namespace to the useMapping function.

If you like to create an improvement that will pass the namespace to the global functions, you're welcome, just make sure all the tests will pass :)

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

No branches or pull requests

3 participants