Skip to content

Commit e42ed2b

Browse files
committed
refactor: optimize bundle
1 parent f9fc4ba commit e42ed2b

File tree

4 files changed

+10
-28
lines changed

4 files changed

+10
-28
lines changed

src/core/infiniteQueryObserver.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,10 @@ export class InfiniteQueryObserver<
5454
super(client, options)
5555
}
5656

57-
protected init(
58-
options: InfiniteQueryObserverOptions<
59-
TData,
60-
TError,
61-
TQueryFnData,
62-
TQueryData
63-
>
64-
) {
57+
protected bindMethods(): void {
58+
super.bindMethods()
6559
this.fetchNextPage = this.fetchNextPage.bind(this)
6660
this.fetchPreviousPage = this.fetchPreviousPage.bind(this)
67-
super.init(options)
6861
}
6962

7063
setOptions(

src/core/mutationObserver.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ export class MutationObserver<
4444

4545
this.client = client
4646
this.setOptions(options)
47+
this.bindMethods()
48+
this.updateResult()
49+
}
4750

48-
// Bind exposed methods
51+
protected bindMethods(): void {
4952
this.mutate = this.mutate.bind(this)
5053
this.reset = this.reset.bind(this)
51-
52-
// Update result
53-
this.updateResult()
5454
}
5555

5656
setOptions(

src/core/queriesObserver.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@ export class QueriesObserver extends Subscribable<QueriesObserverListener> {
4141
}
4242
}
4343

44-
hasListeners(): boolean {
45-
return this.listeners.length > 0
46-
}
47-
4844
destroy(): void {
4945
this.listeners = []
5046
this.observers.forEach(observer => {

src/core/queryObserver.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,13 @@ export class QueryObserver<
6161
this.client = client
6262
this.options = options
6363
this.initialDataUpdateCount = 0
64+
this.bindMethods()
65+
this.setOptions(options)
66+
}
6467

65-
// Bind exposed methods
68+
protected bindMethods(): void {
6669
this.remove = this.remove.bind(this)
6770
this.refetch = this.refetch.bind(this)
68-
69-
// Initialize
70-
this.init(options)
71-
}
72-
73-
protected init(
74-
options: QueryObserverOptions<TData, TError, TQueryFnData, TQueryData>
75-
) {
76-
// Set options
77-
this.setOptions(options)
7871
}
7972

8073
protected onSubscribe(): void {

0 commit comments

Comments
 (0)