Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
const mapBranchesGetter = <G extends keyof BranchesStore>(
getter: G
): BranchesStore[G] => {
return this.context.rootGetters[`branches/${getter}`]
}
const getBranch = mapBranchesGetter('getBranch')
const mapGetter = <S, G extends keyof S>(namespace: string, getter: string): S[G] => {
return this.context.rootGetters[`${namespace}/${getter}`]
}
const gB = mapGetter<BranchesStore, 'getBranch'>('branches', 'getBranch')
const mapGetter = <S, G extends keyof S>(store: S, getter: G): S[G] => {
return this.context.rootGetters[`${(store as any).namespace}/${getter}`]
}
const getBranch = mapGetter(BranchesStore, 'getBranch')
interface Store {
namespace: string
}
const mapGetter = <S>(store: Store) => <G extends keyof S>(
getter: G
): S[G] => this.context.rootGetters[`${store.namespace}/${getter}`]
const mapBranchesGetter = mapGetter<BranchesStore>(BranchesStore)
const getBranch = mapBranchesGetter('getBranch')
const mapGetter = <S>(namespace: string) => <G extends keyof S>(
getter: G
): S[G] => this.context.rootGetters[`${namespace}/${getter}`]
const getBranch = mapGetter<BranchesStore>('branches')('getBranch')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.