Skip to content

Commit

Permalink
add watch on defineModel
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandre BERTRAND committed Sep 26, 2024
1 parent 79c2041 commit 9981c94
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@hublot-io/define-model",
"type": "module",
"version": "1.0.3",
"version": "1.0.4",
"description": "defineModel implementation for vue 2.7 according to 3.4 usage",
"main": "src/index.ts",
"repository": "git@github.com:hublot-io/defineModel.git",
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function defineModel<T>(modelValue : string = 'input') : Ref<T>{
setTimeout(() => {
watch(__instance.$props, () => {
__internalValue.value = __instance.$props.value as T
})
}, { deep : true})

})
}
Expand All @@ -48,7 +48,7 @@ export function defineModel<T>(modelValue : string = 'input') : Ref<T>{
watch(__internalValue, () => {
if(__internalValue.value !== binding.value)
bus.$emit(vnode.context!.$vnode.tag! + '-' + binding.arg, __internalValue.value);
})
}, { deep : true})
})

bus.$on('directive-update-' + modelValue, ({el, binding, vnode}) => { 
Expand All @@ -60,7 +60,7 @@ export function defineModel<T>(modelValue : string = 'input') : Ref<T>{
watch(__internalValue, () => {
if(modelValue === 'input')
__instance.$emit(modelValue, __internalValue.value);
})
}, { deep : true})

return __internalValue as Ref<T>

Expand Down

0 comments on commit 9981c94

Please sign in to comment.