Liking cljdoc? Tell your friends :D

taia.ds.datastar.use-cases.process-event

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).
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).
raw docstring

await-renderclj

(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.
sourceraw docstring

event-timeout-msclj

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.
sourceraw docstring

process-eventclj

(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.
sourceraw docstring

run-event!clj

(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).
sourceraw docstring

start-flow!clj

(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}.
sourceraw docstring

stop-flow!clj

(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.
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