You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
399 B
TypeScript
27 lines
399 B
TypeScript
2 years ago
|
import { ref } from "vue";
|
||
|
|
||
|
export function useBoolean(initValue = false) {
|
||
|
const bool = ref(initValue);
|
||
|
|
||
|
function setBool(value: boolean) {
|
||
|
bool.value = value;
|
||
|
}
|
||
|
function setTrue() {
|
||
|
setBool(true);
|
||
|
}
|
||
|
function setFalse() {
|
||
|
setBool(false);
|
||
|
}
|
||
|
function toggle() {
|
||
|
setBool(!bool.value);
|
||
|
}
|
||
|
|
||
|
return {
|
||
|
bool,
|
||
|
setBool,
|
||
|
setTrue,
|
||
|
setFalse,
|
||
|
toggle
|
||
|
};
|
||
|
}
|