Liking cljdoc? Tell your friends :D

moira.context

Implementation of the interceptor pattern based on an asynchronous promise chain.

Interceptors map hook functions to the three execution stages :enter, :leave, and :error. All hook functions are optional, will be passed the current execution context, and need to return an updated context.

When executing a context, first each :enter hook is triggered in order. After that, each intereptor's :leave hook will be invoked in reverse order. At any point, when an error occurs the execution of remaining interceptors is terminated and the :error function of previously processed interceptors is triggered in reverse order.

The ::queue of pending interceptors and ::stack of partially processed inteceptors are always present on the context. It is perfectly valid for interceptor hooks to alter those in order to change execution.

The current error is available via ::error. To catch an error return a context with the key removed. To signal an error return a context with the ::error key present.

Implementation of the interceptor pattern based on an asynchronous promise
chain.

Interceptors map hook functions to the three execution stages `:enter`,
`:leave`, and `:error`. All hook functions are optional, will be passed
the current execution context, and need to return an updated context.

When executing a context, first each `:enter` hook is triggered in order.
After that, each intereptor's `:leave` hook will be invoked in reverse order.
At any point, when an error occurs the execution of remaining interceptors is
terminated and the `:error` function of previously processed interceptors is
triggered in reverse order.

The `::queue` of pending interceptors and `::stack` of partially processed
inteceptors are always present on the context. It is perfectly valid for
interceptor hooks to alter those in order to change execution.

The current error is available via `::error`. To catch an error return a
context with the key removed. To signal an error return a context with the
`::error` key present.
raw docstring

->excljs

(->ex v data)
source

done?cljs

(done? ctx n)

Returns true, if there are no more pending execution steps.

Returns true, if there are no more pending execution steps.
sourceraw docstring

emitcljs

(emit ctx n)
source

enqueuecljs

(enqueue ctx n txs)

Add interceptors to the end of the execution queue.

Add interceptors to the end of the execution queue.
sourceraw docstring

enter-1cljs

(enter-1 ctx n)

Execute next enter step.

Returns a promise resolving to the updated context. Fails gracefully, if not applicable.

Execute next enter step.

Returns a promise resolving to the updated context. Fails gracefully, if not
applicable.
sourceraw docstring

error?cljs

(error? ctx n)

Returns true, if execution is in error stage.

Returns true, if execution is in error stage.
sourceraw docstring

executecljs

(execute ctx n txs)

Apply a chain of interceptors txs to context ctx.

ctx can be a plain map and will be elevated to be an executable context by enqueueing txs. Returns a promise resolving to the updated context.

Apply a chain of interceptors `txs` to context `ctx`.

`ctx` can be a plain map and will be elevated to be an executable context by
enqueueing `txs`. Returns a promise resolving to the updated context.
sourceraw docstring

execute-1cljs

(execute-1 ctx n)

Execute next enter, leave, or error step.

Returns a promise resolving to the updated context. Fails gracefully, if not applicable.

Execute next enter, leave, or error step.

Returns a promise resolving to the updated context. Fails gracefully, if not
applicable.
sourceraw docstring

execute-allcljs

(execute-all ctx n)

Execute all enter, leave, or error steps.

Returns a promise resolving to the updated context. Fails gracefully, if not applicable.

Execute all enter, leave, or error steps.

Returns a promise resolving to the updated context. Fails gracefully, if not
applicable.
sourceraw docstring

into-queuecljs

(into-queue coll xs)
source

into-stackcljs

(into-stack coll xs)
source

leave-1cljs

(leave-1 ctx n)

Execute next leave or error step.

Returns a promise resolving to the updated context. Fails gracefully, if not applicable.

Execute next leave or error step.

Returns a promise resolving to the updated context. Fails gracefully, if not
applicable.
sourceraw docstring

queue?cljs

(queue? v)
source

stackcljs

(stack ctx n txs)

Add inteceptors to the top of the execution stack.

Add inteceptors to the top of the execution stack.
sourceraw docstring

terminatecljs

(terminate ctx n)

Drop execution of any pending interceptors and immediately switch to the leave stage.

Drop execution of any pending interceptors and immediately switch to the
leave stage.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close