Skip to content

Commit 9ef64d1

Browse files
committed
Deprecates Skia values
1 parent bdb9759 commit 9ef64d1

File tree

2 files changed

+45
-8
lines changed

2 files changed

+45
-8
lines changed

package/src/values/api.ts

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,45 @@
1-
import type { ISkiaValueApi } from "./types";
1+
import type {
2+
AnimationState,
3+
ISkiaValueApi,
4+
SkiaAnimation,
5+
SkiaClockValue,
6+
SkiaMutableValue,
7+
SkiaValue,
8+
} from "./types";
29

310
declare global {
411
var SkiaValueApi: ISkiaValueApi;
512
}
613

714
const { SkiaValueApi } = global;
8-
export const ValueApi = SkiaValueApi;
15+
16+
const deprecatedWarning = () => {
17+
console.warn(
18+
`Skia values are deprecated and will be removed in the next Skia release.
19+
Please use Reanimated instead: https://shopify.github.io/react-native-skia/docs/animations/animations`
20+
);
21+
};
22+
23+
export const ValueApi = {
24+
createValue<T>(initialValue: T): SkiaMutableValue<T> {
25+
deprecatedWarning();
26+
return SkiaValueApi.createValue(initialValue);
27+
},
28+
createComputedValue<R>(
29+
cb: () => R,
30+
values: SkiaValue<unknown>[]
31+
): SkiaValue<R> {
32+
deprecatedWarning();
33+
return SkiaValueApi.createComputedValue(cb, values);
34+
},
35+
createClockValue(): SkiaClockValue {
36+
deprecatedWarning();
37+
return SkiaValueApi.createClockValue();
38+
},
39+
createAnimation<S extends AnimationState = AnimationState>(
40+
cb: (t: number, state: S | undefined) => S
41+
): SkiaAnimation {
42+
deprecatedWarning();
43+
return SkiaValueApi.createAnimation(cb);
44+
},
45+
};

package/src/values/types.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,26 +48,26 @@ export interface ISkiaValueApi {
4848
* Creates a new value that holds the initial value and that
4949
* can be changed.
5050
*/
51-
createValue: <T>(initialValue: T) => SkiaMutableValue<T>;
51+
createValue<T>(initialValue: T): SkiaMutableValue<T>;
5252
/**
5353
* Creates a computed value. This is a calculated value that returns the result of
5454
* a function that is called with the values of the dependencies.
5555
*/
56-
createComputedValue: <R>(
56+
createComputedValue<R>(
5757
cb: () => R,
5858
values: Array<SkiaValue<unknown>>
59-
) => SkiaValue<R>;
59+
): SkiaValue<R>;
6060
/**
6161
* Creates a clock value where the value is the number of milliseconds elapsed
6262
* since the clock was created
6363
*/
64-
createClockValue: () => SkiaClockValue;
64+
createClockValue(): SkiaClockValue;
6565
/**
6666
* Creates an animation that is driven from a clock and updated every frame.
6767
* @param cb Callback to calculate next value from time.
6868
* @returns An animation object that can control a value.
6969
*/
70-
createAnimation: <S extends AnimationState = AnimationState>(
70+
createAnimation<S extends AnimationState = AnimationState>(
7171
cb: (t: number, state: S | undefined) => S
72-
) => SkiaAnimation;
72+
): SkiaAnimation;
7373
}

0 commit comments

Comments
 (0)