Giter VIP home page Giter VIP logo

todo-row-versioning's Introduction

Replicache logo

todo-row-versioning

This is a demonstration of the Row Version Strategy.

It implements the classic TodoMVC app, with one difference:

It supports sharing. You can create multiple lists, and share different lists with different users.

Try it out at: https://todo-row-versioning.onrender.com/.

The sharing is completely dynamic: when somebody shares something with you, it syncs to you automatically. When they unshare it, it disappears.

What's more the sharing is "real". You only sync the data you actually have access to. The subset of data you sync changes dynamically based on what is shared with you.

This is a simple demonstration of a more general concept: With Row Versioning the data that is synced can be any arbitrary query of the database. The data that is synced is call the sync extent. Each user, or even each device can have its own extent, and it can change at any time.

The server will correctly send to the requesting client the difference from its last pull, even if the only thing that changed was the extent and the underlying data is the same.

Notes

  • In this demo, the Client View Records -- the caches of responses previously sent to clients -- are stored in server process memory. This works fine for a single-node server like this demo, but for a distributed server (or serverless) you'll need to store these in something like Redis. It's OK if they time out, the worst that will happen is the client will do a full sync.
  • The extent is stored in this demo per-user (across the user's tabs). This is accomplished by storing the extent in a Replicache entry that is also synced. The extent is changed with a mutator, just like any other Replicache data.

1. Setup

Install Postgres

You will need a local Postgres database to use this sample. On MacOS, we recommend Postgres.app.

Get your Replicache License Key

$ npx replicache get-license

Set your VITE_REPLICACHE_LICENSE_KEY environment variable

$ export VITE_REPLICACHE_LICENSE_KEY="<your license key>"

Install and Build

$ npm install; npm run build;

2. Develop

Create a new, empty database

psql -c 'create database todo'

Start frontend and backend watcher

$ DATABASE_URL='postgresql://localhost/todo' npm run watch --ws

Provides an example integrating replicache with react in a simple todo application.

Deploying to Render

A render blueprint example is provided to deploy the application.

Open the render.yaml file and add your license key

- key: VITE_REPLICACHE_LICENSE_KEY
    value: <license_key>

Commit the changes and follow the direction on Deploying to Render /client /shared /server package.json

todo-row-versioning's People

Contributors

aboodman avatar cesara avatar arv avatar grgbkr avatar kyleamathews avatar

Stargazers

Ethan Davidson avatar Larry Eitel avatar  avatar Declan L. Scott avatar Jamie avatar Brit Gardner avatar Hendry Sadrak avatar Andrew Ross avatar  avatar nichoth avatar texoport avatar Aliaksandr Drankou avatar Julian Benegas avatar

Watchers

Larry Eitel avatar  avatar

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.