:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
import type { QueryState } from './types'
const noop = (): void => undefined
export function loadingQuery<T>(): QueryState<T> {
return { data: undefined, isLoading: true, isError: false, error: null, isRefetching: false, refetch: noop }
}
export function connectionLoadingQuery<T>(offline: boolean, refetch: () => unknown = noop): QueryState<T> {
return offline
? errorQuery(new Error("You're offline. Your data will load when your connection returns."), refetch)
: { ...loadingQuery<T>(), refetch }
}
export function errorQuery<T>(error: Error, refetch: () => unknown = noop): QueryState<T> {
return { data: undefined, isLoading: false, isError: true, error, isRefetching: false, refetch }
}
export function successQuery<T>(
data: T,
options: { isRefetching?: boolean; refetch?: () => unknown } = {}
): QueryState<T> {
return {
data,
isLoading: false,
isError: false,
error: null,
isRefetching: options.isRefetching ?? false,
refetch: options.refetch ?? noop,
}
}