export * from 'react-query' ; export type { ServerFunction , ServerFunctionContext } from './types' ; import { useMutationFunctionBrowser , useQueryFunctionBrowser } from './browser' ; import { useMutationFunctionServer , useQueryFunctionServer } from './server' ; import type { FunctionMutationOptions , FunctionQueryOptions , FunctionReturnType , NonContextFunctionArgs , ServerFunction , } from './types' ; param fn param factoryOptions example export function createQueryFunction < T extends ServerFunction > ( fn , factoryOptions ? ) { return function useBoundQueryFunction ( args , options ? ) { if ( process . env . NOSTALGIE_BUILD_TARGET === 'browser' ) { if ( ! isFunctionFacade ( fn ) ) { throw new Error ( 'Invariant violation: Attempting to invoke a server function not decorated by the Proxy facade' ) ; } return useQueryFunctionBrowser ( fn , args , Object . assign ( { } , factoryOptions , options ) ) ; } else { return useQueryFunctionServer ( fn , args , Object . assign ( { } , factoryOptions , options ) ) ; } } ; } export function useQueryFunction < T extends ServerFunction > ( fn , args , options ? ) { if ( process . env . NOSTALGIE_BUILD_TARGET === 'browser' ) { if ( ! isFunctionFacade ( fn ) ) { throw new Error ( 'Invariant violation: Attempting to invoke a server function not decorated by the Proxy facade' ) ; } return useQueryFunctionBrowser ( fn , args , options ) ; } else { return useQueryFunctionServer ( fn , args , options ) ; } } param fn param factoryOptions example export function createMutationFunction < T extends ServerFunction > ( fn , factoryOptions ? ) { return function useBoundMutationFunction ( options ? ) { if ( process . env . NOSTALGIE_BUILD_TARGET === 'browser' ) { if ( ! isFunctionFacade ( fn ) ) { throw new Error ( 'Invariant violation: Attempting to invoke a server function not decorated by the Proxy facade' ) ; } return useMutationFunctionBrowser ( fn , Object . assign ( { } , factoryOptions , options ) ) ; } else { return useMutationFunctionServer ( fn , Object . assign ( { } , factoryOptions , options ) ) ; } } ; } interface FunctionFacade { name : string ; } function isFunctionFacade ( fn ) { return fn && typeof fn === 'object' && ( fn as any ) . name && typeof ( fn as any ) . name === 'string' ; }