Skip to content

Instantly share code, notes, and snippets.

@nickmessing
Created April 22, 2018 09:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickmessing/dfc8264ecc17d68ed5aaa82bd253d4e5 to your computer and use it in GitHub Desktop.
Save nickmessing/dfc8264ecc17d68ed5aaa82bd253d4e5 to your computer and use it in GitHub Desktop.
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