Liking cljdoc? Tell your friends :D

dev.zeko.stube.registry

The component registry.

In stube, a component is a plain map of the form

{:component/id      :auth/login
 :component/doc     "Prompt for credentials."
 :component/init    (fn [args] state-map)
 :component/render  (fn [self]  hiccup)
 :component/handle  (fn [self event] [self' effects])
 :component/keep    #{:signal-keys}
 :on-foo            (fn [self answer-value] [self' effects])
 …}

Behaviour lives in the values; the key under which the kernel finds them is by namespaced convention. Resume keys (:on-foo, :on-step-3, …) are looked up dynamically when an [:answer …] effect pops a child frame: the parent's :instance/resume value names the function to call.

The registry maps :component/id to the component map. It is held in a single atom so component definitions can be evaluated at namespace load time the same way defmulti defmethods are.

The component registry.

In stube, a *component* is a plain map of the form

    {:component/id      :auth/login
     :component/doc     "Prompt for credentials."
     :component/init    (fn [args] state-map)
     :component/render  (fn [self]  hiccup)
     :component/handle  (fn [self event] [self' effects])
     :component/keep    #{:signal-keys}
     :on-foo            (fn [self answer-value] [self' effects])
     …}

Behaviour lives in the values; the key under which the kernel finds them
is by namespaced convention.  Resume keys (`:on-foo`, `:on-step-3`, …)
are looked up dynamically when an `[:answer …]` effect pops a child
frame: the parent's `:instance/resume` value names the function to call.

The registry maps `:component/id` to the component map.  It is held in a
single atom so component definitions can be evaluated at namespace load
time the same way `defmulti` defmethods are.
raw docstring

allclj

(all)

Snapshot of every registered component, keyed by id. Handy from the REPL; not used internally.

Snapshot of every registered component, keyed by id.  Handy from the
REPL; not used internally.
sourceraw docstring

clear!clj

(clear!)

Drop every component from the registry. Intended for tests.

Drop every component from the registry.  Intended for tests.
sourceraw docstring

helpclj

(help id)

Return the docstring registered for component id, or nil.

Return the docstring registered for component `id`, or nil.
sourceraw docstring

lookupclj

(lookup id)

Return the component map for id, or nil if none is registered.

Return the component map for `id`, or nil if none is registered.
sourceraw docstring

lookup!clj

(lookup! id)

Like lookup but throws if the component is unknown. Used by the kernel where a missing component is an unrecoverable bug.

Like [[lookup]] but throws if the component is unknown.  Used by the
kernel where a missing component is an unrecoverable bug.
sourceraw docstring

register!clj

(register! cdef)

Add or replace a component definition. Returns the registered map.

Add or replace a component definition.  Returns the registered map.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close