Liking cljdoc? Tell your friends :D

emmy.viewer

This namespace contains functions for building Reagent fragments that are renderable by Clerk (see emmy.clerk) or Portal (see emmy.portal).

This namespace contains functions for building Reagent fragments that are
renderable by Clerk (see [[emmy.clerk]]) or Portal (see [[emmy.portal]]).
raw docstring

expandclj/s

(expand v)

If v has a fn? (say, f) registered as Clerk viewer metadata, recurses with the expanded value (f v). Else, returns v unchanged.

If `v` has a `fn?` (say, `f`) registered as Clerk viewer metadata, recurses
with the expanded value `(f v)`. Else, returns `v` unchanged.
sourceraw docstring

fragmentclj/s

(fragment v)
(fragment v viewer-or-xform)

Given some quoted form v, adds metadata that allows the libraries supported by Emmy-Viewers to eval and render v as a Reagent component.

Optionally takes a Clerk viewer or transforming function viewer-or-xform to be applied at render-time and adds that into the metadata instead of the default [[reagent-viewer]].

Given some quoted form `v`, adds metadata that allows the libraries supported
by Emmy-Viewers to eval and render `v` as a Reagent component.

Optionally takes a Clerk viewer or transforming function `viewer-or-xform` to
be applied at render-time and adds that into the metadata instead of the
default [[reagent-viewer]].
sourceraw docstring

getclj/s

(get sym k)

Given some symbol sym representing an atom and a key for the value inside the atom, returns a client-side fragment of the form (get @sym k).

If sym is a map?, acts like clojure.core/get.

If sym is anything else, get treats it as an IDeref and returns (clojure.core/get @sym k).

Given some symbol `sym` representing an atom and a key for the value inside the
atom, returns a client-side fragment of the form `(get @sym k)`.

If `sym` is a `map?`, acts like `clojure.core/get`.

If `sym` is anything else, [[get]] treats it as an `IDeref` and
returns `(clojure.core/get @sym k)`.
sourceraw docstring

get-inclj/s

(get-in sym path)

Given some symbol sym representing an atom and an accessor path into the value inside the atom, returns a client-side fragment of the form (get-in @sym path).

If sym is a map?, acts like clojure.core/get-in.

If sym is anything else, get treats it as an IDeref and returns (clojure.core/get-in @sym path).

Given some symbol `sym` representing an atom and an accessor path into the
value inside the atom, returns a client-side fragment of the form `(get-in @sym
path)`.

If `sym` is a `map?`, acts like `clojure.core/get-in`.

If `sym` is anything else, [[get]] treats it as an `IDeref` and
returns `(clojure.core/get-in @sym path)`.
sourceraw docstring

with-letclj/smacro

(with-let [sym init & more] & body)

Macro wrapper around with-state that allows you to provide the body directly, vs providing a function f as in with-state. with-let takes any number of binding pairs, and treats each as a separate wrapping of with-state.

For example:

(with-let [a {:k "v"}
           b {:k2 "v2"}]
  [:pre (merge @~a @~b)]`)

is equivalent to

(with-state {:k "v"}
  (fn [a]
    (with-state {:k2 "v2"}
      (fn [b]
        [:pre (merge @~a @~b)]))))
Macro wrapper around [[with-state]] that allows you to provide the body
directly, vs providing a function `f` as in [[with-state]]. [[with-let]] takes
any number of binding pairs, and treats each as a separate wrapping
of [[with-state]].

For example:

```clojure
(with-let [a {:k "v"}
           b {:k2 "v2"}]
  [:pre (merge @~a @~b)]`)
```

is equivalent to

```clojure
(with-state {:k "v"}
  (fn [a]
    (with-state {:k2 "v2"}
      (fn [b]
        [:pre (merge @~a @~b)]))))
```
sourceraw docstring

with-paramsclj/s

(with-params {:keys [params atom]} f)

Takes:

  • A map of the form
{:atom <symbol representing a reagent.core/atom>
 :params <sequence of keys from the dereferenced atom>}
  • a function f that takes (count params) parameters and returns a new function

and returns an instance of [[ParamF]] that the various viewer plugins will know how to interpret, based on where the return value of with-params is being used.

Takes:

- A map of the form

```clojure
{:atom <symbol representing a reagent.core/atom>
 :params <sequence of keys from the dereferenced atom>}
```

- a function `f` that takes `(count params)` parameters and returns a new
  function

and returns an instance of [[ParamF]] that the various viewer plugins will
know how to interpret, based on where the return value of [[with-params]] is
being used.
sourceraw docstring

with-stateclj/s

(with-state init f)

This function takes

  • an initial value init for a client-side reagent.core/atom
  • a function f of type <symbol> => <reagent fragment>

And returns a new reagent fragment that allows for stateful, reactive interaction with init via the <symbol>.

All metadata from the return value of f is transferred over to the returned form.

For example:

(with-state {:k "v"}
  (fn [sym] [:pre (get sym :k)]))

;;=> (reagent.core/with-let
;;     [G__95940 (reagent.core/atom {:k "v"})]
;;     [:pre (clojure.core/get @G__95940 :k)])
This function takes

- an initial value `init` for a client-side `reagent.core/atom`
- a function `f` of type `<symbol> => <reagent fragment>`

And returns a new reagent fragment that allows for stateful, reactive
interaction with `init` via the `<symbol>`.

All metadata from the return value of `f` is transferred over to the returned
form.

For example:
```clojure
(with-state {:k "v"}
  (fn [sym] [:pre (get sym :k)]))

;;=> (reagent.core/with-let
;;     [G__95940 (reagent.core/atom {:k "v"})]
;;     [:pre (clojure.core/get @G__95940 :k)])
```
sourceraw docstring

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

× close