Releases: fernandoescolar/types-vue
Releases · fernandoescolar/types-vue
Version 1.1.0
Added vuex store @Getter
decorator an option to set the access mode:
import { Module, VuexModule, Getter } from 'types-vue';
@Module({ namespaced: true })
export default class extends VuexModule {
_list: string[] = []];
@Getter({ mode: 'value'})
listValue(): string[] {
return this._list;
}
@Getter({ mode: 'reference'})
listReference(): string[] {
return this._list;
}
}
If you set the mode as 'reference' you can modify the original vuex store state. If you set it as 'value' you will get a copy of the original object:
export default class TestComponent extends Vue {
@MapGetter({ namespace: 'list-store' })
listValue;
@MapGetter({ namespace: 'list-store' })
listReference;
addItemListValue(): void {
// it should not modify the store object
this.listValue.push('hello');
}
addItemListReference(): void {
// it should do modify the store object
this.listReference.push('hello');
}
}
This parameter is NOT required.