Liking cljdoc? Tell your friends :D

Dependency injection

DI is a dependency injection framework that allows you to define dependencies as cheaply as defining function arguments.

It uses plain clojure functions and associative destructuring to define a graph of functions and stateful objects.

(defn handler [{get-user `get-user} ring-req]
  ...
  (get-user user-id)
  ...)

(defn get-user [{ds `db/datasource} id]
  ...)

(defn jetty [{handler `handler
              port    "PORT"}]
  ...)

(di/start `jetty)

Resources

Docs:

License

Copyright © 2022 Mikhail Kuzmin

Licensed under Eclipse Public License v2.0 (see LICENSE).

Can you improve this documentation?Edit on GitHub

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

× close