Liking cljdoc? Tell your friends :D

dk.simongray.like-minded.document

The documents of a sync: their names, and the envelope around the state of a device, encoded and decoded with the options of the state.

An envelope is a map like this:

{:version    1                     ; of the state's format
 :device     "8f1c9e2a-…"          ; the device that wrote it
 :written-at #inst "2026-09-26T…"  ; by the clock of that device
 :app        "my-app"              ; the app that wrote it, optional
 :kind       "my-app/notes"        ; the kind of state, optional
 :state      {…}}                  ; the whole state of that device

The options of the state are those of dk.simongray.like-minded.

The documents of a sync: their names, and the envelope around the state
of a device, encoded and decoded with the options of the state.

An envelope is a map like this:

    {:version    1                     ; of the state's format
     :device     "8f1c9e2a-…"          ; the device that wrote it
     :written-at #inst "2026-09-26T…"  ; by the clock of that device
     :app        "my-app"              ; the app that wrote it, optional
     :kind       "my-app/notes"        ; the kind of state, optional
     :state      {…}}                  ; the whole state of that device

The options of the state are those of dk.simongray.like-minded.
raw docstring

decodeclj/s

(decode s {:keys [codec] :or {codec edn-codec} :as opts})

The envelope in the document s, decoded with the options of the state opts.

It throws ::malformed when s isn't an envelope. It throws so too for an envelope of the kind of state of opts, in their version of the format or an older one, when the :problem of their CRDT finds a problem in its state.

The envelope in the document `s`, decoded with the options of the state
`opts`.

It throws ::malformed when `s` isn't an envelope. It throws so too for an
envelope of the kind of state of `opts`, in their version of the format
or an older one, when the :problem of their CRDT finds a problem in its
state.
sourceraw docstring

device-document?clj/s

(device-document? doc opts)

Whether the listed document doc is one that a device writes, by the extension that the options of the state opts give.

Whether the listed document `doc` is one that a device writes, by the
extension that the options of the state `opts` give.
sourceraw docstring

edn-codecclj/s

The codec of documents in EDN, the default. A codec is a map of the :extension of the names of the documents, and the functions that :encode an envelope as the body of a document and :decode it.

An app that keeps values of its own in its state, e.g. with tagged literals, gives a codec of its own.

The codec of documents in EDN, the default. A codec is a map of the
:extension of the names of the documents, and the functions that
:encode an envelope as the body of a document and :decode it.

An app that keeps values of its own in its state, e.g. with tagged
literals, gives a codec of its own.
sourceraw docstring

encodeclj/s

(encode state at)
(encode state at {:keys [app kind codec] :or {codec edn-codec} :as opts})

The document of state written at at with the options of the state opts, encoded by their codec.

It's an envelope with the version of the state's format, the device, the state, and the :app and :kind of opts, if any.

The document of `state` written at `at` with the options of the state
`opts`, encoded by their codec.

It's an envelope with the version of the state's format, the device,
the state, and the :app and :kind of `opts`, if any.
sourceraw docstring

extensionclj/s

(extension opts)

The extension of the names of the documents, by the codec of the options of the state opts.

The extension of the names of the documents, by the codec of the options
of the state `opts`.
sourceraw docstring

for-deviceclj/s

(for-device state at opts)

The document that the device of state writes at at, with the options of the state opts and their :app, as a map of its :name and :body.

The document that the device of `state` writes at `at`, with the options
of the state `opts` and their :app, as a map of its :name and :body.
sourceraw docstring

name-ofclj/s

(name-of device opts)

The name of the document that the device device writes, with the options of the state opts.

The name of the document that the device `device` writes, with the
options of the state `opts`.
sourceraw docstring

same-kind?clj/s

(same-kind? envelope opts)

Whether the envelope holds the kind of state of the options opts, which it does unless both name a :kind and the kinds differ.

Whether the `envelope` holds the kind of state of the options `opts`,
which it does unless both name a :kind and the kinds differ.
sourceraw docstring

skew-toleranceclj/s

How far ahead of now a document can be written before the report says that its device's clock is ahead: a minute, in milliseconds.

How far ahead of now a document can be written before the report says
that its device's clock is ahead: a minute, in milliseconds.
sourceraw docstring

statesclj/s

(states fetched at opts)

The states in the documents fetched, read at at with the options of the state opts, as a map of :states and a :report.

Each document is a map of :name and :body. The report has a diagnostic for each of these:

  • :sync/unreadable-document, a body that doesn't read
  • :sync/other-kind, a document of another kind of state, which is left out
  • :sync/newer-format, a document in a newer version of the state's format, which is left out
  • :sync/clock-skew, a device whose clock is ahead of this one

It throws when opts give no CRDT, rather than report every document as one that doesn't read.

The states in the documents `fetched`, read at `at` with the options of
the state `opts`, as a map of :states and a :report.

Each document is a map of :name and :body. The report has a diagnostic
for each of these:

- :sync/unreadable-document, a body that doesn't read
- :sync/other-kind, a document of another kind of state, which is left
  out
- :sync/newer-format, a document in a newer version of the state's
  format, which is left out
- :sync/clock-skew, a device whose clock is ahead of this one

It throws when `opts` give no CRDT, rather than report every document
as one that doesn't read.
sourceraw docstring

versionclj/s

The version of the state's format that a document records, unless the options give another. It changes only when the meaning of a key of the state changes, since a reader merges the keys it doesn't know by their shape.

The version of the state's format that a document records, unless the
options give another. It changes only when the meaning of a key of the
state changes, since a reader merges the keys it doesn't know by their
shape.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close