Skip to content

Commit 0cbd161

Browse files
committed
feat: add reset query params
1 parent 366821a commit 0cbd161

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/mobx-inifinite-query.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
runInAction,
2323
} from 'mobx';
2424

25-
import { MobxQueryInvalidateParams } from './mobx-query';
25+
import { MobxQueryInvalidateParams, MobxQueryResetParams } from './mobx-query';
2626

2727
export interface MobxInfiniteQueryConfig<
2828
TData,
@@ -311,10 +311,11 @@ export class MobxInfiniteQuery<
311311
return await this.queryObserver.refetch(options);
312312
}
313313

314-
async reset() {
314+
async reset(params?: MobxQueryResetParams) {
315315
await this.queryClient.resetQueries({
316316
queryKey: this.options.queryKey,
317317
exact: true,
318+
...params,
318319
});
319320
}
320321

src/mobx-query.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
hashKey,
55
InvalidateQueryFilters,
66
QueryClient,
7+
QueryFilters,
78
QueryKey,
89
QueryObserver,
910
QueryObserverOptions,
@@ -23,6 +24,9 @@ import {
2324
export interface MobxQueryInvalidateParams
2425
extends Partial<Omit<InvalidateQueryFilters, 'queryKey' | 'exact'>> {}
2526

27+
export interface MobxQueryResetParams
28+
extends Partial<Omit<QueryFilters, 'queryKey' | 'exact'>> {}
29+
2630
export interface MobxQueryConfig<
2731
TData,
2832
TError = DefaultError,
@@ -239,10 +243,11 @@ export class MobxQuery<
239243
this._result = nextResult || {};
240244
}
241245

242-
async reset() {
246+
async reset(params?: MobxQueryResetParams) {
243247
await this.queryClient.resetQueries({
244248
queryKey: this.options.queryKey,
245249
exact: true,
250+
...params,
246251
});
247252
}
248253

0 commit comments

Comments
 (0)