Liking cljdoc? Tell your friends :D

co.multiply.tropical.resource

Shared, reference-counted stateful resources, such as subscriptions to a database or poll loops.

There is one physical resource per key, however many sessions watch it. It opens on the first subscriber. After the last subscriber leaves, it lingers for linger-ms and then closes, unless someone subscribes again first. The linger absorbs remount churn: switching back and forth, navigation, and reconnects.

A resource is opened by a subject, (fn [emit!] undo), as in Missionary's observe. Keys are a call site and its args. Islands subscribe with co.multiply.tropical.hooks/observe, which holds a subscription for as long as the island's renders keep asking for it: a render that stops, or the island unmounting, releases it. Nobody calls release! by hand.

The instances of shared states (co.multiply.tropical.shared) are resources too, under keys of their own: they open holding a value, with a linger of their state's, and change by its swap!, not by a subject.

A resource whose task fails is closed: its value becomes Failed, so its readers throw, and the next subscriber to its key opens a new one.

Shared, reference-counted stateful resources, such as subscriptions to a
database or poll loops.

There is one physical resource per key, however many sessions watch it. It
opens on the first subscriber. After the last subscriber leaves, it lingers for
`linger-ms` and then closes, unless someone subscribes again first. The linger
absorbs remount churn: switching back and forth, navigation, and reconnects.

A resource is opened by a subject, `(fn [emit!] undo)`, as in Missionary's
`observe`. Keys are a call site and its args. Islands subscribe with
`co.multiply.tropical.hooks/observe`, which
holds a subscription for as long as the island's renders keep asking for it: a
render that stops, or the island unmounting, releases it. Nobody calls
`release!` by hand.

The instances of shared states (`co.multiply.tropical.shared`) are resources
too, under keys of their own: they open holding a value, with a linger of
their state's, and change by its `swap!`, not by a subject.

A resource whose task fails is closed: its value becomes `Failed`, so its
readers throw, and the next subscriber to its key opens a new one.
raw docstring

!entriesclj

The open resources, for display: an atom of a map keyed by resource, which changes only as a resource opens, lingers or closes. Watch it through summary: (use-watch resource/!entries resource/summary).

The open resources, for display: an atom of a map keyed by
resource, which changes only as a resource opens, lingers or closes. Watch
it through `summary`: `(use-watch resource/!entries resource/summary)`.
sourceraw docstring

!totalsclj

How many resources have opened and closed since the JVM started, as an atom of {:opened :closed}.

How many resources have opened and closed since the JVM started,
as an atom of `{:opened :closed}`.
sourceraw docstring

linger-msclj

How long, in ms, a resource lingers after its last reader leaves, unless it was opened with a :linger-ms of its own.

How long, in ms, a resource lingers after its last reader leaves, unless it
was opened with a `:linger-ms` of its own.
sourceraw docstring

summaryclj

(summary)
(summary entries)

The open resources, for display: key -> {:state :subscribers}, the state :connecting, :live or :lingering. Of the registry, or of entries, a value it held.

The open resources, for display: key -> `{:state :subscribers}`, the state
`:connecting`, `:live` or `:lingering`. Of the registry, or of `entries`, a
value it held.
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