The use case: process a component's event. It runs as a
clojure.core.async.flow of two procs, each in its own namespace:
in-chan ──▶ :controller ──:to-view──▶ :view ──▶ out-chan (state machine) (render) process-event.controller process-event.view
The messages are described in process-event.common. Everything here is
plain data in and out: the caller resolves the component (its machine and
render fn, as vars) and turns a request into a message (adapters); the
rules about the ctx and the transition are the domain's.
Two lifetimes:
process-event):
put the event, take the render or time out, stop the flow;start-flow!), so a later event — a browser POST or a server
send-event! — goes in through the same in-chan.
Either way nothing is kept between events: each starts from the client's
signals (a click) or from the machine's initial state (a server event,
which brings what it needs as its params).The use case: process a component's event. It runs as a
`clojure.core.async.flow` of two procs, each in its own namespace:
in-chan ──▶ :controller ──:to-view──▶ :view ──▶ out-chan
(state machine) (render)
process-event.controller process-event.view
The messages are described in `process-event.common`. Everything here is
plain data in and out: the caller resolves the component (its machine and
render fn, as vars) and turns a request into a message (adapters); the
rules about the ctx and the transition are the domain's.
Two lifetimes:
- a DEFAULT component's event gets a flow of its own (`process-event`):
put the event, take the render or time out, stop the flow;
- a CONNECTED component's flow lives as long as its SSE stream
(`start-flow!`), so a later event — a browser POST or a server
`send-event!` — goes in through the same in-chan.
Either way nothing is kept between events: each starts from the client's
signals (a click) or from the machine's initial state (a server event,
which brings what it needs as its params).(await-render ch-or-promise component-name event-name)Takes one render from ch (a promise is deref'd), or throws on timeout.
An error message is rethrown as the exception it carries.
Takes one render from `ch` (a promise is deref'd), or throws on timeout. An error message is rethrown as the exception it carries.
How long a caller waits for an event's render before giving up.
How long a caller waits for an event's render before giving up.
(process-event {:keys [component-name component-id] :as component} msg)Processes one event of a one-shot component in a flow of its own: built
from the resolved component (see start-flow!), given msg, stopped once
it has answered. Returns {:event :initial-ctx :ctx :html …}. Throws what a
step threw, or an ex-info with ::timeout.
Processes one event of a one-shot component in a flow of its own: built
from the resolved `component` (see `start-flow!`), given `msg`, stopped once
it has answered. Returns {:event :initial-ctx :ctx :html …}. Throws what a
step threw, or an ex-info with ::timeout.(run-event! {:keys [in-chan out-chan component-name]} msg)Puts msg on a flow you started (start-flow!) and waits for its render
on the flow's out-chan. Returns {:event :initial-ctx :ctx :html …}; throws
like await-render. Not for a flow whose out-chan someone else drains (a
connection's flow — send it events with a :reply instead).
Puts `msg` on a flow you started (`start-flow!`) and waits for its render
on the flow's out-chan. Returns {:event :initial-ctx :ctx :html …}; throws
like `await-render`. Not for a flow whose out-chan someone else drains (a
connection's flow — send it events with a :reply instead).(start-flow! {:keys [machine-var component-fn-var component-name component-id]})Builds, starts and resumes a component's flow. component is the resolved
component — {:machine-var :component-fn-var} — plus its :component-name and
:component-id. Returns {:flow :in-chan :out-chan :component-name :component-id}.
Builds, starts and resumes a component's flow. `component` is the resolved
component — {:machine-var :component-fn-var} — plus its :component-name and
:component-id. Returns {:flow :in-chan :out-chan :component-name :component-id}.(stop-flow! {:keys [flow in-chan out-chan]})Stops the flow's procs and closes its in/out channels. Idempotent.
Stops the flow's procs and closes its in/out channels. Idempotent.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |