Skip to content

TodoMVC ​

🚧 Pardon Our Stardust!

The @warp-drive/tutorials package isn't published yet, so the npx command below doesn't work. Until it is, run the starter from a clone of the WarpDrive repo:

sh
git clone https://github.com/warp-drive-data/warp-drive.git
cd warp-drive
pnpm install
cd packages/tutorials/todomvc-ember/starter
pnpm start

Let's build the data layer of a TodoMVC app with WarpDrive.

The starter ships the Ember UI and a local API. You write the WarpDrive part: requests, builders, one handler and a few cache updates. No models, adapters or serializers. Your first request renders todos in chapter 1. From chapter 4 on, each chapter adds one operation: create, edit, toggle, delete, then the bulk controls. Most chapters start with a problem every data layer has, and show how WarpDrive handles it.

The finished TodoMVC app: three todos, one completed, and a footer that says 2 items left

Chapters ​

ChapterYou'll use
1First requeststore.request and <Request>
2Why that workedthe four ideas WarpDrive is built on
3Request buildersbuilders and a handler
4CreatecreateRecord and invalidation
5Edit titlecheckout and updateRecord
6Togglestore.cache.patch
7DeletedeleteRecord
8Bulk operationsbulk requests, then where to go next

Before you start ​

You should know TypeScript and have built something with Ember. You don't need to know WarpDrive.

You need Node.js and pnpm.

Get the starter ​

sh
npx @warp-drive/tutorials@canary todomvc-ember
cd todomvc-ember
pnpm install
pnpm start

Open the URL Vite prints. You should see the TodoMVC header and the filters, with no todos between them. That's right: nothing requests todos until chapter 1.

The starter app: the todos header, the new-todo input, and a footer with only the All, Active and Completed filters

What's in the starter ​

todomvc-ember/
  api-worker/     the API, in a service worker; you won't touch it
  app/
    components/   the TodoMVC UI, finished
    data/
      builders/   you write these, next to a shipped utils.ts
      schemas/    the todo schema, finished
      store.ts    the store; you add a handler in chapter 3
    routes/       one per filter: index (All), active, completed

The UI is done. You add WarpDrive calls to a few routes and components, and each chapter tells you which.

The API ​

The app talks to a JSON:API server at /api. It runs in the browser as a service worker, so there's nothing to start, and it keeps your changes across reloads. It begins with three todos. To reset it, clear the site data in your browser's developer tools.

Released under the MIT License.