fun-map Api
fun-map Api
(closeable r close-fn)
Returns a wrapped plain value, which implements IDref and Closeable, the close-fn is an effectual function with no argument.
When used inside a life cycle map, its close-fn when get called when closing the map.
Returns a wrapped plain value, which implements IDref and Closeable, the close-fn is an effectual function with no argument. When used inside a life cycle map, its close-fn when get called when closing the map.
(fnk args & body)
A shortcut for fw
macro. Returns a simple FunctionWrapper which depends on
args
key of the fun-map, it will focus on the keys also.
A shortcut for `fw` macro. Returns a simple FunctionWrapper which depends on `args` key of the fun-map, it will *focus* on the keys also.
(fun-map m & {:keys [trace-fn]})
Returns a new fun-map.
A fun-map is a special map which will automatically unwrap a value if it's a wrapper when accessed by key. A wrapper is anything which wrapped a ordinary value inside. Many clojure data structures are wrapper, such as atom, ref, future, delay, agent etc. In fact, anything implements clojure.lang.IDRef interface is a wrapper.
FuntionWrapper is another wrapper can be used in a fun-map, which wraps a function, it will be called with the fun-map itself as the argument.
Map m is the underlying storage of a fun-map, fun-map does not change its property except accessing values.
Options:
Example:
(fun-map {:a 35 :b (delay (println "hello from b!"))}
Returns a new fun-map. A fun-map is a special map which will automatically *unwrap* a value if it's a wrapper when accessed by key. A wrapper is anything which wrapped a ordinary value inside. Many clojure data structures are wrapper, such as atom, ref, future, delay, agent etc. In fact, anything implements clojure.lang.IDRef interface is a wrapper. FuntionWrapper is another wrapper can be used in a fun-map, which wraps a function, it will be called with the fun-map itself as the argument. Map m is the underlying storage of a fun-map, fun-map does not change its property except accessing values. Options: - :trace-fn An Effectful function for globally FunctionWrapper calling trace which accept key and value as its argument. Example: (fun-map {:a 35 :b (delay (println "hello from b!"))}
(fw arg-map & body)
Returns a FunctionWrapper of an anonymous function defined by body.
Since a FunctionWrapper's function will be called with the map itself as the
argument, this macro using a map arg-map
as its argument. It follows the
same syntax of clojure's associative destructure. You may use :keys
, :as
,
:or
inside.
Special key :wrappers
specify additional wrappers of function wrapper:
[]
for naive one, no cache, no trace.:spec
a spec that the value must conform.:focus
A form that will be called to check if the function itself need
to be called. It must be pure functional and very effecient.:trace
A trace function, if the value updated, it will be called with key
and the function's return value.Special option :par? true
will make dependencies accessing parallel.
Example:
(fw {:keys [a b] :as m :trace (fn [k v] (println k v)) :focus (select-keys m [:a :b])} (+ a b))
Returns a FunctionWrapper of an anonymous function defined by body. Since a FunctionWrapper's function will be called with the map itself as the argument, this macro using a map `arg-map` as its argument. It follows the same syntax of clojure's associative destructure. You may use `:keys`, `:as`, `:or` inside. Special key `:wrappers` specify additional wrappers of function wrapper: - `[]` for naive one, no cache, no trace. - default to specable cached traceable implementation. which supports special keys: - `:spec` a spec that the value must conform. - `:focus` A form that will be called to check if the function itself need to be called. It must be pure functional and very effecient. - `:trace` A trace function, if the value updated, it will be called with key and the function's return value. Special option `:par? true` will make dependencies accessing parallel. Example: (fw {:keys [a b] :as m :trace (fn [k v] (println k v)) :focus (select-keys m [:a :b])} (+ a b))
Life cycle protocol, signature just like java.io.Closeable, being a protocol gives user ability to extend
Life cycle protocol, signature just like java.io.Closeable, being a protocol gives user ability to extend
(halt! this)
(life-cycle-map m)
returns a fun-map can be shutdown orderly.
Any FunctionWrapper supports Closeable
in this map will be considered
as a component, its close
method will be called in reversed order of its
creation when the map itself closing.
Notice only accessed components will be shutdown.
returns a fun-map can be shutdown orderly. Any FunctionWrapper supports `Closeable` in this map will be considered as a component, its `close` method will be called in reversed order of its creation when the map itself closing. Notice only accessed components will be shutdown.
(lookup f)
Returns a semi Associative instance by mapping single arity function f as argument to return value.
Returns a semi Associative instance by mapping single arity function f as argument to return value.
(touch m)
Forcefully evaluate all entries of a map and returns itself.
Forcefully evaluate all entries of a map and returns itself.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close