Skip to content

Commit

Permalink
fix(query): update for signatures of createSuccessObserverResult and …
Browse files Browse the repository at this point in the history
…createPendingObserverResult (#175)
  • Loading branch information
Dewscntd authored May 10, 2024
1 parent 50ee757 commit 39bc985
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions query/src/lib/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
DefaultError,
QueryObserverResult,
QueryObserverSuccessResult,
QueryObserverSuccessResult
} from '@tanstack/query-core';
import { Observable, Subject, firstValueFrom, takeUntil } from 'rxjs';

Expand All @@ -23,9 +24,9 @@ export function toPromise<T>({
return firstValueFrom(source.pipe(signal ? takeUntil(cancel) : (s) => s));
}

export function createSuccessObserverResult<T>(
export function createSuccessObserverResult<T, Error = DefaultError>(
data: T,
): QueryObserverResult<T> {
): QueryObserverResult<T, Error> {
return {
data,
isLoading: false,
Expand All @@ -34,10 +35,10 @@ export function createSuccessObserverResult<T>(
isPending: false,
isSuccess: true,
status: 'success',
} as QueryObserverSuccessResult<T>;
} as QueryObserverSuccessResult<T, Error>;
}

export function createPendingObserverResult<T>(): QueryObserverResult<T> {
export function createPendingObserverResult<T = unknown, Error = DefaultError>(): QueryObserverResult<T, Error> {
return {
isError: false,
isLoading: true,
Expand All @@ -46,5 +47,5 @@ export function createPendingObserverResult<T>(): QueryObserverResult<T> {
isSuccess: false,
fetchStatus: 'fetching',
status: 'pending',
} as QueryObserverResult<T>;
} as QueryObserverResult<T, Error>;
}

0 comments on commit 39bc985

Please sign in to comment.