import React from "react"
import {runOnUI} from "react-native-reanimated"

// biome-ignore lint/suspicious/noExplicitAny: not useful to type
export function useWorkletUiCallback<TArgs extends any[]>(fcn: (...a: TArgs) => void, deps: any[]) {
    return React.useCallback((...a: TArgs) => {
        "worklet"
        if (_WORKLET) {
            fcn(...a)
        } else {
            runOnUI(fcn)(...a)
        }
        // biome-ignore lint/correctness/useExhaustiveDependencies: ignore
    }, deps)
}
