MCPcopy Create free account
hub / github.com/SvelteStack/svelte-query / getDefaultState

Method getDefaultState

src/queryCore/core/query.ts:527–559  ·  view source on GitHub ↗
(
    options: QueryOptions<TQueryFnData, TError, TData, TQueryKey>
  )

Source from the content-addressed store, hash-verified

525 }
526
527 protected getDefaultState(
528 options: QueryOptions<TQueryFnData, TError, TData, TQueryKey>
529 ): QueryState<TData, TError> {
530 const data =
531 typeof options.initialData === 'function'
532 ? (options.initialData as InitialDataFunction<TData>)()
533 : options.initialData
534
535 const hasInitialData = typeof options.initialData !== 'undefined'
536
537 const initialDataUpdatedAt = hasInitialData
538 ? typeof options.initialDataUpdatedAt === 'function'
539 ? (options.initialDataUpdatedAt as () => number | undefined)()
540 : options.initialDataUpdatedAt
541 : 0
542
543 const hasData = typeof data !== 'undefined'
544
545 return {
546 data,
547 dataUpdateCount: 0,
548 dataUpdatedAt: hasData ? initialDataUpdatedAt ?? Date.now() : 0,
549 error: null,
550 errorUpdateCount: 0,
551 errorUpdatedAt: 0,
552 fetchFailureCount: 0,
553 fetchMeta: null,
554 isFetching: false,
555 isInvalidated: false,
556 isPaused: false,
557 status: hasData ? 'success' : 'idle',
558 }
559 }
560
561 protected reducer(
562 state: QueryState<TData, TError>,

Callers 1

constructorMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected