Skip to content

@powersync/[email protected]

Compare
Choose a tag to compare
@github-actions github-actions released this 30 Jul 07:58
· 3 commits to main since this release
a95ccbb

Minor Changes

  • c7d2b53: - [Internal] Updated implementation to use shared WatchedQuery implementation.

  • c7d2b53: - Added the ability to limit re-renders by specifying a rowComparator for query results. The useQuery hook will only emit data changes when the data has changed.

    // The data here will maintain previous object references for unchanged items.
    const { data } = useQuery('SELECT * FROM lists WHERE name = ?', ['aname'], {
      rowComparator: {
        keyBy: (item) => item.id,
        compareBy: (item) => JSON.stringify(item)
      }
    });
    • Added the ability to subscribe to an existing instance of a WatchedQuery
    import { useWatchedQuerySubscription } from '@powersync/react';
    
    const listsQuery = powerSync
      .query({
        sql: `SELECT * FROM lists`
      })
      .differentialWatch();
    
    export const ListsWidget = (props) => {
      const { data: lists } = useWatchedQuerySubscription(listsQuery);
    
      return (
        <div>
          {lists.map((list) => (
            <div key={list.id}>{list.name}</div>
          ))}
        </div>
      );
    };

Patch Changes