live-model
TypeScript icon, indicating that this package has built-in type declarations

1.0.0-alpha.0 • Public • Published

Live Model

Live Model provides a local cache to your API or remote database, so that your app responds immediately, whether your user has gigabit internet, an unstable connection, or is offline!

Installation

npm install live-model@alpha

Usage

⚠️  Under development!

import { liveTable } from "live-model";
import { useQuery } from "live-model/react";

interface ToDo {
    id: string;
    title: string;
}

const todosTable = liveTable<ToDo>("todos");

export function App() {
    const todos = useQuery(todosTable);
    return (
        <div>
            <ul>
                {todos.map((todo) => (
                    <li key={todo.id}>{todo.title}</li>
                ))}
            </ul>
            <button onClick={() => todosTable.add({ title: "New" })}>
                Create To-Do
            </button>
        </div>
    );
}

Licence

MIT

Package Sidebar

Install

npm i live-model

Weekly Downloads

0

Version

1.0.0-alpha.0

License

MIT

Unpacked Size

2.78 kB

Total Files

7

Last publish

Collaborators

  • andreterron