-
-
Save nickmessing/dfc8264ecc17d68ed5aaa82bd253d4e5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Vue from 'vue' | |
import { mapActions, mapGetters } from 'vuex' | |
import { ActionGet, ActionCreate, ActionPatch, GetterList } from 'feathers-vuex' | |
interface Person { // should be identical to the model | |
firstName: string | |
lastName: string | |
} | |
interface PersonGetters { | |
people: GetterList<Person> | |
} | |
interface PersonActions { | |
getPerson: ActionGet<Person> | |
createPerson: ActionCreate<Person> | |
patchPerson: ActionPatch<Person> | |
} | |
export default Vue.extend({ | |
computed: { | |
...(mapGetters('people', { people: 'list' }) as PersonGetters) | |
}, | |
methods: { | |
...(mapActions('people', { getPerson: 'get', createPerson: 'create', patchPerson: 'patch' }) as PersonActions) | |
} | |
// people can use this.list or this.createPerson() fully typed here | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment