Skip to content

Commit

Permalink
Simplify uiValueGetter
Browse files Browse the repository at this point in the history
  • Loading branch information
piaskowyk committed Dec 21, 2023
1 parent 07500bb commit dfa97c4
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/reanimated2/mutables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ import { valueSetter } from './valueSetter';

const SHOULD_BE_USE_WEB = shouldBeUseWeb();

function uiValueGetter<T>(sharedValue: SharedValue<T>): T {
const uiValueGetter = executeOnUIRuntimeSync(<T>(sv: SharedValue<T>): T => {
'worklet';
return sharedValue.value;
}

const getValueFromMutable = executeOnUIRuntimeSync(uiValueGetter);
return sv.value;
});

export function makeUIMutable<T>(initial: T) {
'worklet';
Expand Down Expand Up @@ -86,7 +84,7 @@ export function makeMutable<T>(initial: T): SharedValue<T> {
},
get value(): T {
if (!SHOULD_BE_USE_WEB) {
return getValueFromMutable(mutable) as T;
return uiValueGetter(mutable) as T;
}
return value;
},
Expand Down

0 comments on commit dfa97c4

Please sign in to comment.