Skip to content

Commit 04dba65

Browse files
committed
use shallowRef for vue bindings
1 parent 5902830 commit 04dba65

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

.changeset/plenty-buckets-teach.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@effect-atom/atom-vue": patch
3+
---
4+
5+
use shallowRef for vue bindings

packages/atom-vue/src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import * as Effect from "effect/Effect"
1010
import * as Exit from "effect/Exit"
1111
import { globalValue } from "effect/GlobalValue"
1212
import type { ComputedRef, InjectionKey, Ref } from "vue"
13-
import { computed, inject, ref, watchEffect } from "vue"
13+
import { computed, inject, shallowRef, watchEffect } from "vue"
1414

1515
/**
1616
* @since 1.0.0
@@ -74,7 +74,7 @@ export const injectRegistry = (): Registry.Registry => {
7474
const useAtomValueRef = <A extends Atom.Atom<any>>(atom: () => A) => {
7575
const registry = injectRegistry()
7676
const atomRef = computed(atom)
77-
const value = ref(undefined as any as A)
77+
const value = shallowRef(undefined as any as A)
7878
watchEffect((onCleanup) => {
7979
onCleanup(registry.subscribe(atomRef.value, (nextValue) => {
8080
value.value = nextValue
@@ -201,7 +201,7 @@ export const useAtomSet = <
201201
*/
202202
export const useAtomRef = <A>(atomRef: () => AtomRef.ReadonlyRef<A>): Readonly<Ref<A>> => {
203203
const atomRefRef = computed(atomRef)
204-
const value = ref<A>(atomRefRef.value.value)
204+
const value = shallowRef<A>(atomRefRef.value.value)
205205
watchEffect((onCleanup) => {
206206
const atomRef = atomRefRef.value
207207
onCleanup(atomRef.subscribe((next) => {

0 commit comments

Comments
 (0)