Liking cljdoc? Tell your friends :D

active.clojure.dynj

Thin layer over dynamic vars for implicit dependency injection. Dynjs can be used to have better control over side effects, to abstract over different possible interpretations of an aspect of a program or to make things easier for testing.

Main usage patterns:

(declare-dynj eff [a])

(defn foo []
  (assert (= 4 (eff 2))))

(defn square [a] (* a a))

(foo) ;; => throws exception

(binding [eff square]
  (foo))

((with-bindings* {#'eff square} foo))

Thin layer over dynamic vars for implicit dependency injection. Dynjs
can be used to have better control over side effects, to abstract
over different possible interpretations of an aspect of a program or
to make things easier for testing.

Main usage patterns:

```
(declare-dynj eff [a])

(defn foo []
  (assert (= 4 (eff 2))))

(defn square [a] (* a a))

(foo) ;; => throws exception

(binding [eff square]
  (foo))

((with-bindings* {#'eff square} foo))

```
raw docstring

bind-fn*clj

(bind-fn* binding-map f)

Returns a function that will call f with the given map of dynj implementations in place. Note that the returned function can then be called on other threads, too.

Returns a function that will call `f` with the given map of dynj
implementations in place. Note that the returned function can then
be called on other threads, too.
sourceraw docstring

bindingcljmacro

(binding bindings & body)

Binds one or more dynjs to implementations during the evaluation of body.

(declare-dynj add-user! [user])

(binding [add-user! db-add-user!]
  ...)
Binds one or more dynjs to implementations during the evaluation of `body`.

```
(declare-dynj add-user! [user])

(binding [add-user! db-add-user!]
  ...)
```
sourceraw docstring

bound-fn*clj

(bound-fn* f)

Returns a function that will call f with the same dynj implementations in place as there are now. Passes all arguments though to f.

Returns a function that will call `f` with the same dynj
implementations in place as there are now. Passes all arguments though to f.
sourceraw docstring

declare-dynjcljmacro

(declare-dynj name params)
(declare-dynj name docstring params)

Declares name as a dynamic injection point, to be bound to an implementation/value later via binding. params and docstring are for documentation purposes.

Declares `name` as a dynamic injection point, to be bound to an
implementation/value later via [[binding]]. `params` and `docstring`
are for documentation purposes.
sourceraw docstring

defn-dynjcljmacro

(defn-dynj name params & body)

Declares name as a dynamic injection point, to be bound to an implementation/value later via binding, and adds a default implementation. Typically you would throw a helpful exception in the body.

Declares `name` as a dynamic injection point, to be bound to an
implementation/value later via [[binding]], and adds a default
implementation. Typically you would throw a helpful exception in the
body.
sourceraw docstring

merge-dynjsclj

(merge-dynjs binding-map & more)

Like merge, but asserts that all keys are dynj vars, and the same vars are not bound to different implementations.

Like merge, but asserts that all keys are dynj vars, and the same
vars are not bound to different implementations.
sourceraw docstring

with-bindings*clj

(with-bindings* binding-map thunk)

Calls (thunk) and binds implementations via a map of dynj vars during the evaluation of (thunk).

Calls `(thunk)` and binds implementations via a map of
dynj vars during the evaluation of `(thunk)`.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close