Giter Site home page Giter Site logo

Comments (3)

sgwilym avatar sgwilym commented on July 20, 2024 1

Hi @michielbdejong. The goal of ReplicaCache is to provide a synchronous API to the (asynchronous) Replica, in order to be easily used by certain libraries or frameworks. It does this by watching for events from Replica, and seeing if they contain any documents which have been queried for previously. If a document satisfies this criteria, it adds it to an in-memory cache of documents.

The reason the page is rendering before any data is available is because ReplicaCache must synchronously return a result when it is queried.

  1. On the first call, it does not have anything its cache, so it returns an empty result.
  2. Then In the background it works to (asynchronously) retrieve the result, and fires an update when it has it.
  3. This result is then added to ReplicaCache's in-memory cache of documents, so that it can be retrieved synchronously thereafter.

In short, the reason you do not see any results until you call cache.queryDocs is because the ReplicaCache does not know what you are interested in until you do.

from earthstar.

michielbdejong avatar michielbdejong commented on July 20, 2024

This is not a blocker for me, I can work around it now that I know about it, but it felt quirky so I'm simply curious why this works this way.

And thanks for this awesome project btw!

from earthstar.

michielbdejong avatar michielbdejong commented on July 20, 2024

Thanks, that makes a lot of sense now!

from earthstar.

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.