(assoc-opaque-keys ctx app-ctx a-frame-router)
add the opaque keys to the interceptor context
they are removed from reported contexts by sanitise-context
add the opaque keys to the interceptor context they are removed from reported contexts by `sanitise-context`
(clear-errors context)
Removes any associated ::errors
from context
Removes any associated `::errors` from `context`
The Interceptor specific keys that are added to contexts
The Interceptor specific keys that are added to contexts
(dissoc-context-keys context)
Removes all interceptor related keys from context
Removes all interceptor related keys from `context`
(enqueue context interceptors)
Adds interceptors
to the end of the interceptor queue within context
Adds `interceptors` to the end of the interceptor queue within `context`
(enter-all context)
Process the :queue
of context
, calling each :enter
fn
in turn.
If an error is raised it is captured, stored in the context
s :error
key,
and the queue is cleared (to prevent further processing.)
Process the `:queue` of `context`, calling each `:enter` `fn` in turn. If an error is raised it is captured, stored in the `context`s `:error` key, and the queue is cleared (to prevent further processing.)
(enter-next {queue :a-frame.interceptor-chain/queue
stack :a-frame.interceptor-chain/stack
_history :a-frame.interceptor-chain/history
:as context})
Executes the next ::enter
interceptor queued within context
, returning a
promise that will resolve to the next pr-loop-context
action to take
Executes the next `::enter` interceptor queued within `context`, returning a promise that will resolve to the next [[pr-loop-context]] action to take
(execute app-ctx a-frame-router interceptor-chain initial-context)
Returns a Promise encapsulating the execution of the given InterceptorContext
.
Runs all :enter
interceptor fns (in FIFO order) and then all :leave
fns
(in LIFO order) returning the end result context
map.
If an error occurs during execution :enter
processing is terminated and the
:error
handlers of all executed interceptors are called (in LIFO order),
with the original error wrapped in an ex-info with ex-data containing the
::context at the point of failure - this can be used to resume processing
from the failure point
If the resulting context
still contains an error after this processing it
will be re-thrown when the execution promise is realised.
Returns a Promise encapsulating the execution of the given [[InterceptorContext]]. Runs all `:enter` interceptor fns (in FIFO order) and then all `:leave` fns (in LIFO order) returning the end result `context` map. If an error occurs during execution `:enter` processing is terminated and the `:error` handlers of all executed interceptors are called (in LIFO order), with the original error wrapped in an ex-info with ex-data containing the ::context at the point of failure - this can be used to resume processing from the failure point If the resulting `context` _still_ contains an error after this processing it will be re-thrown when the execution promise is realised.
(initiate app-ctx a-frame-router interceptor-chain initial-context)
Given a sequence of InterceptorSpec
s and a map of initial-context
values,
returns a new InterceptorContext
ready to execute
Given a sequence of [[InterceptorSpec]]s and a map of `initial-context` values, returns a new [[InterceptorContext]] ready to [[execute]]
An Interceptor, all methods are optional but should be implemented as follows:
::enter
takes 1 or 2 args:
::leave
– takes 1 or 2 args:
::error
– takes two args
All methods may return either promises or plain values.
An Interceptor, all methods are optional but should be implemented as follows: * `::enter` takes 1 or 2 args: - context -> context - context -> data -> context * `::leave` – takes 1 or 2 args: - context -> context - context -> data -> context * `::error` – takes two args - context -> error -> context All methods may return either promises or plain values.
(interceptor-fn-history-thunk interceptor-fn-key interceptor-spec context error)
returns a [<history-entry> <interceptor-fn-thunk>]
returns a [<history-entry> <interceptor-fn-thunk>]
the interceptor chain is created with a list of InterceptorSpecs. each InterceptorSpec is either
providing data like this allows a pure-data (in the re-frame sense - roughly something which has no opaque objects and is serializable/deserializable) interceptor chain to be registered, which has numerous benefits
the interceptor chain is created with a list of InterceptorSpecs. each InterceptorSpec is either - simple keyword, referencing a registered interceptor which will cause ::enter and ::leave fns to be invoked with 1-arity, or - a pair of [interceptor-kw interceptor-data]. if there is data (either ::enter-data or ::leave-data) then ::enter and ::leave will be invoked with their 2-arity providing data like this allows a pure-data (in the re-frame sense - roughly something which has no opaque objects and is serializable/deserializable) interceptor chain to be registered, which has numerous benefits
(leave-all context)
Process the ::stack
of context
, calling, in LIFO order.
If an ::error
is present in the context
then the ::error
handling fn
of the interceptors will be called otherwise the :leave
fn
s will be
called.
Any thrown errors will replace the current ::error
with stack unwinding
continuing from that point forwards.
Process the `::stack` of `context`, calling, in LIFO order. If an `::error` is present in the `context` then the `::error` handling `fn` of the interceptors will be called otherwise the `:leave` `fn`s will be called. Any thrown errors will replace the current `::error` with stack unwinding continuing from that point forwards.
(leave-next {stack :a-frame.interceptor-chain/stack
_history :a-frame.interceptor-chain/history
[error :as _errors] :a-frame.interceptor-chain/errors
:as context})
Executes the next ::leave
or ::error
interceptor on the stack within
context
, returning a promise that will resolve to the next
pr-loop-context
action to take
Executes the next `::leave` or `::error` interceptor on the stack within `context`, returning a promise that will resolve to the next [[pr-loop-context]] action to take
(maybe-execute-interceptor-fn interceptor-fn-key interceptor-spec context error)
call an interceptor fn on an interceptor, resolving any supplied data
call an interceptor fn on an interceptor, resolving any supplied data
(normalize-interceptor-spec interceptor-spec)
turns keyword interceptor-specs into maps {::key <interceptor-key>}
turns keyword interceptor-specs into maps {::key <interceptor-key>}
keys which contain opaque data
keys which contain opaque data
(pr-loop-context* context step-fn)
Helper fn to repeat execution of step-fn
against context
inside a promise
loop.
step-fn
should return a tuple of either [::break <value>]
or [::recur <new context>]
. The former will terminate the loop and return <value>
, the
later will pass <new context>
to the next loop iteration.
(Note: this mainly exists to abstract away and minimise the platform specific aspects of handling promise loops.)
Helper fn to repeat execution of `step-fn` against `context` inside a promise loop. `step-fn` should return a tuple of either `[::break <value>]` or `[::recur <new context>]`. The former will terminate the loop and return `<value>`, the later will pass `<new context>` to the next loop iteration. (Note: this mainly exists to abstract away and minimise the platform specific aspects of handling promise loops.)
(resolve-interceptor-data interceptor-fn-key interceptor-data-specs context)
resolve the interceptor data, returning either
resolve the interceptor data, returning either - [data-val] if there was data specified - nil if no data was specified
(resume app-ctx a-frame-router err-or-resume-context)
(resume app-ctx
a-frame-router
error-handler
suppressed-error-handler
err-or-resume-context)
resume a failed interceptor chain, from either a thrown exception or a logged resume-context
resume a failed interceptor chain, from either a thrown exception or a logged resume-context
(sanitise-context context)
remove impure / opaque data from a context
remove impure / opaque data from a context
(terminate context)
Removes all queued interceptors from context
Removes all queued interceptors from `context`
(unwrap-original-error e)
unwrap layers of error wrapping (in case of nested :dispatch) to get at the causal exception
unwrap layers of error wrapping (in case of nested :dispatch) to get at the causal exception
(wrap-interceptor-error resume-context new-context e)
wrap an exception and add to the interceptor errors
wrap an exception and add to the interceptor errors
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close