mirror of
https://github.com/kevin-DL/build-gmail-clone-with-vue-3.git
synced 2026-01-17 13:14:54 +00:00
Global non-persisted state with useEmailSelection composition function
This commit is contained in:
19
src/composition/useEmailSelection.js
Normal file
19
src/composition/useEmailSelection.js
Normal 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;
|
||||
Reference in New Issue
Block a user