Skip to content

Commit fc67d94

Browse files
Mini-ghosthunterliu1003
authored andcommitted
perf: use getter and setter instead of computed for modelValueLocal
1 parent a060fae commit fc67d94

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

packages/vue-final-modal/src/components/CoreModal/useModelValue.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { computed, nextTick, ref, watch } from 'vue'
1+
import { nextTick, ref, watch } from 'vue'
2+
import type { Ref } from 'vue'
23
import type CoreModal from './CoreModal.vue'
34

45
export function useModelValue(
@@ -16,12 +17,16 @@ export function useModelValue(
1617
const _modelValueLocal = ref<boolean>(false)
1718

1819
/**
19-
* A WritableComputedRef, a only variable to control open or close the modal
20+
* The proxy of `_modelValueLocal`
2021
*/
21-
const modelValueLocal = computed({
22-
get: () => _modelValueLocal.value,
23-
set: setModelValueLocal,
24-
})
22+
const modelValueLocal = {
23+
get value() {
24+
return _modelValueLocal.value
25+
},
26+
set value(val: boolean) {
27+
setModelValueLocal(val)
28+
},
29+
} as Ref<boolean>
2530

2631
/**
2732
* Because of the open/close can be stopped in `@beforeOpen`, `@beforeClose` events.

0 commit comments

Comments
 (0)