mirror of
https://github.com/kevin-DL/build-gmail-clone-with-vue-3.git
synced 2026-01-17 13:14:54 +00:00
Abstract useEmailSelection into separate 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 { 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;
|
||||
Reference in New Issue
Block a user