Abstract useEmailSelection into separate function

This commit is contained in:
Jeffrey Biles
2020-03-17 22:19:30 -07:00
parent 67d539fd03
commit e5b83a407a
2 changed files with 22 additions and 9 deletions

View File

@@ -23,17 +23,11 @@
<script>
import { format } from 'date-fns'
import { ref } from 'vue';
import useEmailSelection from '../composition/useEmailSelection';
export default {
setup(){
let selectedEmailIds = ref(new Set(['1', '5']))
let toggleEmailSelection = (id) => {
if(selectedEmailIds.value.has(id)) {
selectedEmailIds.value.delete(id)
} else {
selectedEmailIds.value.add(id);
}
}
let {selectedEmailIds, toggleEmailSelection} = useEmailSelection();
return {format, selectedEmailIds, toggleEmailSelection}
},
props: {

View File

@@ -0,0 +1,19 @@
import { ref } from 'vue';
export const useEmailSelection = function(){
let selectedEmailIds = ref(new Set(['1', '5']))
let toggleEmailSelection = (id) => {
if(selectedEmailIds.value.has(id)) {
selectedEmailIds.value.delete(id)
} else {
selectedEmailIds.value.add(id);
}
}
return {
selectedEmailIds,
toggleEmailSelection
}
}
export default useEmailSelection;