GithubHelp home page GithubHelp logo

Comments (1)

justinsteven avatar justinsteven commented on June 13, 2024

As an aside, I came across this problem when using a pattern similar to that described at https://stackoverflow.com/a/77329694/22644904

For a table where I have a need for a certain seldomly-touched subset of fields, and where I want liveQuery to rerender only upon a change to those fields OR upon a new row in the table, I'm doing a liveQuery on:

db.myTable.orderBy("[orderIndex+field2+field3]"). /*... SNIP ... */

(I happen to want the results ordered by orderIndex anyway, which is a number field I maintain and which I diligently ensure is distinct across all the rows)

Of course, this requires an additional compound index on the table, but I figured that's cheaper than any alternative that I know of.

My question is: If I'm scared of useMemo(), is that pattern still a clean and cheap way to limit the rerenders from useLiveQuery ? Is there a better way these days?

As an aside to the aside, my fear of useMemo() is that I expect that for every, say, 100 updates to the table in question, only 1 update is going to be the addition of a new row or the mutation of one of the "interesting" subset of fields. I figured liveQuery() would be unnecessarily spamming my component with 99 re-renders for every update that this component actually cares about, causing unnecessary work in considering the memo cache etc.

from dexie.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.