콘텐츠로 이동

Vue, Solid & Svelte Order Boards

이 콘텐츠는 아직 번역되지 않았습니다.

The same small app written three times, once per adapter, on one shared model. It shows the four flows the adapter subpaths cover:

Flow Where to look API
Per-scope state shared/model.ts scoped(), useScoped()
Scope lifetime and hydration each main.ts (Svelte: svelte/Root.svelte) ScopeProvider without a scope, HydrationBoundary, useHydrate
Optimistic mutation App.vue, App.svelte, solid/main.ts useOptimisticAction
Lists same files useCollectionTopK, useCollectionSize
Async data same files useResource on a lazy resource

What the page does:

  1. The balance reads 1,000 on the first render: the provider creates a scope and the snapshot { balance: 1000 } is hydrated into it before any component reads.
  2. The profile shows loading until the lazy resource answers. The request starts when the first component reads it.
  3. Reserve 150 lowers the balance at once and shows pending. When the server answers, the layer is replaced by the server’s balance in one step.
  4. Reserve 100000 is refused by the server. The optimistic edit is reverted and the error is shown.
  5. Pressing both quickly opens two layers. They rebase in creation order and settle independently.
  6. Add order inserts a row; the Top-3 list and the total update incrementally.

React has its own example, the WASM order book.

From the repository root, with the pinned toolchains installed:

Terminal window
pnpm install --frozen-lockfile --ignore-scripts
mise run build:ts
mise run test:adapter-examples
python3 -m http.server 8080 --bind 127.0.0.1 --directory examples/adapter-orders/dist

Open http://127.0.0.1:8080/vue/, /solid/ or /svelte/. The second task bundles the three views into dist/ and runs smoke.mjs, which mounts each view in happy-dom and drives the six steps above through the DOM.

build.mjs uses the bundler and compilers the test workspace already installs (Rolldown, vue/compiler-sfc, svelte/compiler), so the example adds no toolchain of its own. That is also why the Solid view builds its DOM with a small el() helper instead of JSX: no JSX compiler for Solid 2 is installed here. In an application, write it with your usual Solid setup; the zwire calls are the same.