Interface UseSubscriptionOptions<TSubscriptionFnData, TError, TData, TSubscriptionKey>

Type Parameters

  • TSubscriptionFnData = unknown

  • TError = Error

  • TData = TSubscriptionFnData

  • TSubscriptionKey extends QueryKey = QueryKey

Hierarchy

  • UseSubscriptionOptions

Properties

enabled?: boolean

Set this to false to disable automatic resubscribing when the subscription mounts or changes subscription keys. To refetch the subscription, use the refetch method returned from the useSubscription instance. Defaults to true.

onData?: ((data: TData) => void)

Type declaration

    • (data: TData): void
    • This function will fire any time the subscription successfully fetches new data or the cache is updated via setQueryData.

      Parameters

      • data: TData

      Returns void

onError?: ((error: TError) => void)

Type declaration

    • (error: TError): void
    • This callback will fire if the subscription encounters an error and will be passed the error.

      Parameters

      • error: TError

      Returns void

placeholderData?: TSubscriptionFnData | PlaceholderDataFunction<TSubscriptionFnData>

If set, this value will be used as the placeholder data for this particular query observer while the subscription is still in the loading data and no initialData has been provided.

retry?: RetryValue<TError>

If false, failed subscriptions will not retry by default. If true, failed subscriptions will retry infinitely. If set to an integer number, e.g. 3, failed subscriptions will retry until the failed subscription count meets that number. If set to a function (failureCount: number, error: TError) => boolean failed subscriptions will retry until the function returns false.

retryDelay?: RetryDelayValue<TError>

If number, applies delay before next attempt in milliseconds. If function, it receives a retryAttempt integer and the actual Error and returns the delay to apply before the next attempt in milliseconds.

See

https://react-query.tanstack.com/reference/useQuery

retryOnMount?: boolean

If set to false, the subscription will not be retried on mount if it contains an error. Defaults to true.

select?: ((data: TSubscriptionFnData) => TData)

Type declaration

    • (data: TSubscriptionFnData): TData
    • This option can be used to transform or select a part of the data returned by the query function.

      Parameters

      • data: TSubscriptionFnData

      Returns TData

Generated using TypeDoc