org.martinklepsch.derivatives

*derivatives*

dynamic

build

(build spec)
Given a spec return a map of similar structure replacing it's values with
derived atoms built based on the depedency information encoded in the spec

WARNING: This will create derived atoms for all keys so it may lead
to some uneccesary computations To avoid this issue consider using
`derivatives-pool` which manages derivatives in a registry
removing them as soon as they become unused

calc-deps

(calc-deps graph ks)
Calculate all dependencies for `ks` and return a set with the dependencies and `ks`

depend'

(depend' graph node deps)
Variation of `depend` that takes a list of dependencies instead of one

derivatives-pool

(derivatives-pool spec)
Given a derivatives spec return a map with `get!` and `free!` functions.

- (get! derivative-id token) will retrieve a derivative for
  `derivative-id` registering the usage with `token`
- (free! derivative-id token) will indicate the derivative `derivative-id`
  is no longer needed by `token`, if there are no more tokens needing
  the derivative it will be removed

drv

(drv & drv-ks)
Rum mixin to retrieve derivatives for `drv-ks` using the functions in the component context
To get the derived-atom use `get-ref` for swappable client/server behavior

get-ref

(get-ref state drv-k)
Get the derivative identified by `drv-k` from the component state.
When rendering in Clojure this looks for `drv-k` in the dynvar `*derivatives`

IDerivativesPool

protocol

members

get!

(get! this drv-k token)

release!

(release! this drv-k token)

not-required

(not-required drv-map required?)

prefix-id

(prefix-id)

react

(react state drv-k)
Like `get-ref` wrapped in `rum.core/react`

react-all

(react-all state & ks)
React to multiple derivatives in the components state.
If any `ks` are passed, react to those and return their values
in a map. If no `ks` is passed return all available derivatives
deref'ed as a map.

rum-derivatives

(rum-derivatives spec)
Given the passed spec add get!/release! derivative functions to
the child context so they can be seen by components using the `deriv`
mixin.

rum-derivatives*

(rum-derivatives* get-spec-fn)
Like rum-derivatives but get the spec from the arguments passed to the components (`:rum/args`) using `get-spec-fn`

spec->graph

(spec->graph spec)
Turn a given spec into a dependency graph

sync-derivatives!

(sync-derivatives! spec watch-key-prefix drv-map order)
Update the derivatives map `drv-map` so that all keys passed in `order`
are statisfied and any superfluous keys are removed.
Values of superfluous keys that implement IDisposable they will also be disposed.

watchable?

(watchable? x)
Platform-agnostic helper to determine if something is watchable (atom, etc)