From dfa97c40944e58e7dcb76775d8d3488639495bd6 Mon Sep 17 00:00:00 2001 From: Krzysztof Piaskowy Date: Thu, 21 Dec 2023 10:20:03 +0100 Subject: [PATCH] Simplify uiValueGetter --- src/reanimated2/mutables.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/reanimated2/mutables.ts b/src/reanimated2/mutables.ts index 7977a65861d0..a4595fa77937 100644 --- a/src/reanimated2/mutables.ts +++ b/src/reanimated2/mutables.ts @@ -10,12 +10,10 @@ import { valueSetter } from './valueSetter'; const SHOULD_BE_USE_WEB = shouldBeUseWeb(); -function uiValueGetter(sharedValue: SharedValue): T { +const uiValueGetter = executeOnUIRuntimeSync((sv: SharedValue): T => { 'worklet'; - return sharedValue.value; -} - -const getValueFromMutable = executeOnUIRuntimeSync(uiValueGetter); + return sv.value; +}); export function makeUIMutable(initial: T) { 'worklet'; @@ -86,7 +84,7 @@ export function makeMutable(initial: T): SharedValue { }, get value(): T { if (!SHOULD_BE_USE_WEB) { - return getValueFromMutable(mutable) as T; + return uiValueGetter(mutable) as T; } return value; },