Skip to content

Commit 4a7b40c

Browse files
committed
Fix namings and formatting
1 parent d5b3345 commit 4a7b40c

File tree

2 files changed

+19
-18
lines changed

2 files changed

+19
-18
lines changed

src/core/queriesObserver.ts

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -77,45 +77,46 @@ export class QueriesObserver extends Subscribable<QueriesObserverListener> {
7777
const newObservers: QueryObserver[] = []
7878
const newObserversMap: Record<string, QueryObserver> = {}
7979

80-
const defaultedQueryOptions = queries.map(o =>
81-
this.client.defaultQueryObserverOptions(o)
80+
const defaultedQueryOptions = queries.map(options =>
81+
this.client.defaultQueryObserverOptions(options)
8282
)
8383
const matchingObservers = defaultedQueryOptions
84-
.map(o => {
85-
if (o.queryHash == null) {
84+
.map(options => {
85+
if (options.queryHash == null) {
8686
return null
8787
}
88-
const match = prevObserversMap[o.queryHash]
88+
const match = prevObserversMap[options.queryHash]
8989
if (match != null) {
90-
match.setOptions(o, notifyOptions)
90+
match.setOptions(options, notifyOptions)
9191
return match
9292
}
9393
return null
9494
})
9595
.filter(notNullOrUndefined)
9696

9797
const matchedQueryHashes = matchingObservers
98-
.map(o => o?.options.queryHash)
98+
.map(observer => observer?.options.queryHash)
9999
.filter(notNullOrUndefined)
100100
const unmatchedQueries = defaultedQueryOptions.filter(
101-
o =>
102-
o.queryHash !== undefined && !matchedQueryHashes.includes(o.queryHash)
101+
options =>
102+
options.queryHash !== undefined &&
103+
!matchedQueryHashes.includes(options.queryHash)
103104
)
104105

105106
const unmatchedObservers = prevObservers.filter(
106-
p => !matchingObservers.includes(p)
107+
prevObserver => !matchingObservers.includes(prevObserver)
107108
)
108109

109-
const newlyMatchedOrCreatedObservers = unmatchedQueries.map(q => {
110-
if (q.keepPreviousData && unmatchedObservers.length > 0) {
111-
// use the first existing but no longer matched query to keep query data for any new queries
110+
const newlyMatchedOrCreatedObservers = unmatchedQueries.map(options => {
111+
if (options.keepPreviousData && unmatchedObservers.length > 0) {
112+
// use the first observer but no longer matched query to keep query data for any new queries
112113
const firstObserver = unmatchedObservers.splice(0, 1)[0]
113114
if (firstObserver !== undefined) {
114-
firstObserver.setOptions(q, notifyOptions)
115+
firstObserver.setOptions(options, notifyOptions)
115116
return firstObserver
116117
}
117118
}
118-
return this.getObserver(q)
119+
return this.getObserver(options)
119120
})
120121

121122
matchingObservers
@@ -148,7 +149,7 @@ export class QueriesObserver extends Subscribable<QueriesObserverListener> {
148149
)
149150

150151
const hasIndexChange = updatedObservers.newObservers.some(
151-
(o, i) => o !== prevObservers[i]
152+
(observer, index) => observer !== prevObservers[index]
152153
)
153154
if (
154155
prevObservers.length === updatedObservers.newObservers.length &&

src/core/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,6 @@ export function getAbortController(): AbortController | undefined {
457457
/**
458458
* Type predicate to filter an array of null or undefined elements
459459
*/
460-
export function notNullOrUndefined<T>(value: T | null | undefined): value is T {
461-
return value !== null && value !== undefined;
460+
export function notNullOrUndefined<T>(value: T): value is NonNullable<T> {
461+
return value !== null && value !== undefined
462462
}

0 commit comments

Comments
 (0)