Liking cljdoc? Tell your friends :D
ClojureScript only.

cljs-lambda.local

Utilities for the local (e.g. automated tests, REPL interactions) invocation of Lambda handlers. Local invocation is accomplished by passing handlers a stub context object which records completion signals.

Utilities for the local (e.g. automated tests, REPL interactions) invocation
of Lambda handlers.  Local invocation is accomplished by passing handlers a
stub context object which records completion signals.
raw docstring

->contextcljs

(->context & [key-overrides])

Create a context object for use w/ invoke, channel. This is helpful if your want to take advantage of key-overrides to supply different context values for an invocation -- otherwise, no need to use directly.

(invoke wait {:msecs 17} (->context {:function-name "wait"}))

By default, the values for the context keys will match the key names, more or less, e.g. {:function-name "functionName"}.

Create a `context` object for use w/ [[invoke]], [[channel]].  This is
  helpful if your want to take advantage of `key-overrides` to supply different
  context values for an invocation -- otherwise, no need to use directly.

```clojure
(invoke wait {:msecs 17} (->context {:function-name "wait"}))
```

  By default, the values for the context keys will match the key names, more or
  less, e.g. `{:function-name "functionName"}`.
sourceraw docstring

channelcljs

(channel f)
(channel f event)
(channel f event {input-channel :result-channel :as ctx})

Identical semantics to invoke, though the return value is a core.async channel containing either [:succeed <result>] or [:fail <result>].

(deflambda please-repeat [[n x] ctx]
  (promesa/resolved (repeat n x)))

(invoke please-repeat [3 :x])
;; => <Channel [:succeed ["x" "x" "x"]]>
Identical semantics to [[invoke]], though the return value is a `core.async`
  channel containing either `[:succeed <result>]` or `[:fail <result>]`.

```clojure
(deflambda please-repeat [[n x] ctx]
  (promesa/resolved (repeat n x)))

(invoke please-repeat [3 :x])
;; => <Channel [:succeed ["x" "x" "x"]]>
```
sourceraw docstring

invokecljs

(invoke f)
(invoke f event)
(invoke f event {:keys [result-channel] :as ctx})

Utility for local (test, REPL) invocation of Lambda handlers. Returns a promise resolved or rejected with the result of invoking f on the given event (nil in arity 1) and context object (defaulted in lower arities).

(deflambda add [[x y] ctx]
  (go (+ x y)))

(invoke add [-1 2])
;; => <Promise: 1>
Utility for local (test, REPL) invocation of Lambda handlers.  Returns a
  promise resolved or rejected with the result of invoking `f` on the given
  event (nil in arity 1) and `context` object (defaulted in lower arities).

```clojure
(deflambda add [[x y] ctx]
  (go (+ x y)))

(invoke add [-1 2])
;; => <Promise: 1>
```
sourceraw docstring

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

× close