refactor: replace core.async with promesa for all async operations

- Store protocol now returns promesa promises instead of core.async channels
- MemoryStore: `(p/resolved val)` replaces chan+put!+close! ceremony
- IDBStore: `p/create` with resolve/reject wraps IDB callbacks
- sync.cljc: CLJ uses `p/vthread`, CLJS returns native Promise chains
- core.cljc: `p/let` replaces go blocks, timer-based sync loop replaces
  go-loop+alts!, debounced push replaces kick channel
- Tests use `deref` with timeout on promesa promises
- Todomvc example uses `p/let` instead of go/<!
This commit is contained in:
Florian Schroedl
2026-04-16 20:05:08 +02:00
parent fffd934262
commit 973b079ae3
9 changed files with 360 additions and 321 deletions

View File

@@ -1,23 +1,23 @@
(ns pocketbook.store
"Storage protocol for Pocketbook.
All methods return core.async channels.")
All methods return promesa promises.")
(defprotocol PStore
(put-doc! [store doc]
"Write a document to the store. doc is a map:
{:id str, :value any, :version int, :updated int, :deleted bool, :synced bool}
Returns a channel that closes on success.")
Returns a promise that resolves on success.")
(docs-by-prefix [store prefix]
"Get all documents whose id starts with prefix.
Returns a channel yielding a vector of doc maps.")
Returns a promise yielding a vector of doc maps.")
(get-meta [store key]
"Get a metadata value by key.
Returns a channel yielding the value, or nil if not found.")
Returns a promise yielding the value, or nil if not found.")
(set-meta! [store key value]
"Set a metadata value. Returns a channel that closes on success.")
"Set a metadata value. Returns a promise that resolves on success.")
(close-store! [store]
"Close the store and release resources."))