Skip to content

Commit 35cbac1

Browse files
More comparator renames
1 parent d87a902 commit 35cbac1

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

packages/common/src/client/watched/processors/DifferentialQueryProcessor.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export interface WatchedQueryDifferential<RowType> {
4242
}
4343

4444
/**
45-
* Comparator for differentially watched queries which keys and compares items in the result set.
45+
* Row comparator for differentially watched queries which keys and compares items in the result set.
4646
*/
4747
export interface DifferentialWatchedQueryComparator<RowType> {
4848
/**
@@ -65,10 +65,10 @@ export interface DifferentialWatchedQueryOptions<RowType> extends WatchedQueryOp
6565
placeholderData?: RowType[];
6666

6767
/**
68-
* Comparator used to identify and compare rows in the result set.
68+
* Row comparator used to identify and compare rows in the result set.
6969
* If not provided, the default comparator will be used which keys items by their `id` property if available,
7070
* otherwise it uses JSON stringification of the entire item for keying and comparison.
71-
* @defaultValue {@link DEFAULT_COMPARATOR}
71+
* @defaultValue {@link DEFAULT_ROW_COMPARATOR}
7272
*/
7373
rowComparator?: DifferentialWatchedQueryComparator<RowType>;
7474
}
@@ -121,7 +121,7 @@ export const EMPTY_DIFFERENTIAL = {
121121
* It keys items by their `id` property if available, alternatively it uses JSON stringification
122122
* of the entire item for the key and comparison.
123123
*/
124-
export const DEFAULT_COMPARATOR: DifferentialWatchedQueryComparator<any> = {
124+
export const DEFAULT_ROW_COMPARATOR: DifferentialWatchedQueryComparator<any> = {
125125
keyBy: (item) => {
126126
if (item && typeof item == 'object' && typeof item['id'] == 'string') {
127127
return item['id'];
@@ -144,7 +144,7 @@ export class DifferentialQueryProcessor<RowType>
144144

145145
constructor(protected options: DifferentialQueryProcessorOptions<RowType>) {
146146
super(options);
147-
this.comparator = options.rowComparator ?? DEFAULT_COMPARATOR;
147+
this.comparator = options.rowComparator ?? DEFAULT_ROW_COMPARATOR;
148148
}
149149

150150
/*

packages/react/src/hooks/suspense/useSuspenseQuery.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import { useWatchedSuspenseQuery } from './useWatchedSuspenseQuery';
3030
* export const DiffContentComponent = () => {
3131
* // A differential query will emit results when a change to the result set occurs.
3232
* // The internal array object references are maintained for unchanged rows.
33-
* // The returned lists array is read only when a `comparator` is provided.
33+
* // The returned lists array is read only when a `rowComparator` is provided.
3434
* const { data: lists } = useSuspenseQuery('SELECT * from lists', [], {
3535
* rowComparator: {
3636
* keyBy: (item) => item.id,

packages/react/tests/useQuery.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ describe('useQuery', () => {
270270
});
271271

272272
// Verifies backwards compatibility with the previous implementation (no comparison)
273-
it('should emit result data when data changes when not using comparator', async () => {
273+
it('should emit result data when data changes when not using rowComparator', async () => {
274274
const db = openPowerSync();
275275
const wrapper = ({ children }) => <PowerSyncContext.Provider value={db}>{children}</PowerSyncContext.Provider>;
276276
const { result } = renderHook(() => useQuery('SELECT * FROM lists WHERE name = ?', ['aname']), { wrapper });

0 commit comments

Comments
 (0)