What's the frontend of duct?
You say air conditioning? Oh! Fan Coil Unit.
A clojurescript framework, which uses multi-methods to define and implement system unit, uses integrant to inject configuration and stateful dependencies to unit at system startup.
It is highly inspired by the structure of re-frame and duct.
[com.github.itarck/fancoil "0.0.3-SNAPSHOT"] ; Leiningen/Boot
com.github.itarck/fancoil {:mvn/version "0.0.3-SNAPSHOT"} ; Clojure CLI/deps.edn
Name | Desc | Spec | Detail |
---|---|---|---|
db | stored state | ref | ratom,datascript |
chan | flow state | channel | core.async.chan |
subscribe | subscribe reaction | ref-> reaction | tree of reactions |
view | view model | model -> reactions -> react component | reagent, rum |
dispatch | dispatch event | event -> request | |
tap | tap model | value->value | user-defined, for handle, pure function |
handle! | handle! request | request -> effect | default to db-handler |
- inject | inject co-effect | request -> request | support for multiple co-fx |
- handle | handle request | request -> response | db-handler, pure function |
- do! | do! effect | response -> effect | support for multiple fx |
service | long-run for request | go-loop | support for sync and async |
task | once/periodic | e.g. init process |
Definition period: in fancoil.base, the type and interface of a machine is defined by defmulti
(defmulti handle!
"stateful function
request in -> effects out
config: inject, handle, doall!, other resources"
(fn [config signal & rest] signal))
Implementation period: in fancoil.plugin, some methods of base are implemented, you can include them. Or you can use defmethod to implement them in your project. Method may call other methods of same multi-fn, as is common in handle and subscribe.
(defmethod base/handle! :default
[{:keys [doall! handle inject]} signal req]
(let [req (inject :ratom/db req)
resp (handle signal req)]
(doall! resp)))
Runtime period: in fancoil.unit, some integrant init-key method is implemented, and integrant will inject the configuration into the machine when it initializes the system
(defmethod ig/init-key ::handle!
[_ config]
(partial base/handle! config))
(def config
{::handle! {:handle (ig/ref ::handle)
:inject (ig/ref ::inject)
:doall! (ig/ref ::doall!)}
;; other config })
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close