Global non-persisted state with useEmailSelection composition function

This commit is contained in:
Jeffrey Biles
2020-03-29 22:51:32 -07:00
parent c481ec8cb2
commit a4d6663cfd
3 changed files with 47 additions and 14 deletions

View File

@@ -0,0 +1,19 @@
import { reactive } from 'vue';
let emails = new Set()
export const useEmailSelection = function(){
let emailSelection = reactive({
emails: emails,
toggle(id) {
if(this.emails.has(id)) {
this.emails.delete(id)
} else {
this.emails.add(id);
}
},
})
return { emailSelection }
}
export default useEmailSelection;