- 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/<!
24 lines
775 B
Clojure
24 lines
775 B
Clojure
(ns pocketbook.store
|
|
"Storage protocol for Pocketbook.
|
|
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 promise that resolves on success.")
|
|
|
|
(docs-by-prefix [store prefix]
|
|
"Get all documents whose id starts with prefix.
|
|
Returns a promise yielding a vector of doc maps.")
|
|
|
|
(get-meta [store key]
|
|
"Get a metadata value by key.
|
|
Returns a promise yielding the value, or nil if not found.")
|
|
|
|
(set-meta! [store key value]
|
|
"Set a metadata value. Returns a promise that resolves on success.")
|
|
|
|
(close-store! [store]
|
|
"Close the store and release resources."))
|