Liking cljdoc? Tell your friends :D

javelin.core


*env*clj

source

*hoist*clj

source

*pass*clj

source

alts!cljs

(alts! & cells)

Given a number of cells, returns a formula cell whose value is a seq of values from cells that changed in the last update. Note that multiple cells may update atomically, which is why the formula's value is a seq.

Consider:

(def a (cell {:x 1 :y 2}))
(def x (cell= (:x a)))
(def y (cell= (:y a)))
(def z (alts! x y))

then,

(deref z) ;=> (1 2)

(swap! a assoc :x 42)
(deref z) ;=> (42)

(reset! a {:x 10 :y 20})
(deref z) ;=> (10 20)
Given a number of cells, returns a formula cell whose value is a seq of
values from cells that changed in the last update. Note that multiple cells
may update atomically, which is why the formula's value is a seq.

Consider:

    (def a (cell {:x 1 :y 2}))
    (def x (cell= (:x a)))
    (def y (cell= (:y a)))
    (def z (alts! x y))

then,

    (deref z) ;=> (1 2)

    (swap! a assoc :x 42)
    (deref z) ;=> (42)

    (reset! a {:x 10 :y 20})
    (deref z) ;=> (10 20)
sourceraw docstring

bind-symsclj

(bind-syms form)

Given a binding form, returns a seq of the symbols that will be bound.

(bind-syms '[{:keys [foo some.ns/bar] :as baz} baf & quux]) ;=> (foo bar baz baf quux)

Given a binding form, returns a seq of the symbols that will be bound.

(bind-syms '[{:keys [foo some.ns/bar] :as baz} baf & quux])
;=> (foo bar baz baf quux)
sourceraw docstring

cellcljs

(cell x)
(cell x & {:keys [meta]})

Returns a new input cell containing value x. The :meta option can be used to create the cell with the given metadata map.

Returns a new input cell containing value x. The :meta option can be used
to create the cell with the given metadata map.
sourceraw docstring

Cellcljs

source

cell*clj

(cell* x env)
source

cell-doseqclj/smacro

(cell-doseq bindings & body)

Takes a vector of binding-form/collection-cell pairs and one or more body expressions, similar to clojure.core/doseq. Iterating over the collection cells produces a sequence of items that may grow, shrink, or update over time. Whenever this sequence grows the body expressions are evaluated (for side effects) exactly once for each new location in the sequence. Bindings are bound to cells that refer to the item at that location.

Consider:

(def things (cell [{:x :a} {:x :b} {:x :c}]))

(cell-doseq [{:keys [x]} things]
  (prn :creating @x)
  (add-watch x nil #(prn :updating %3 %4)))

;; the following is printed -- note that x is a cell:

:creating :a
:creating :b
:creating :c

Shrink things by removing the last item:

(swap! things pop)

;; the following is printed (because the 3rd item in things is now nil,
;; since things only contains 2 items) -- note that the doit function is
;; not called (or we would see a :creating message):

:updating :c nil

Grow things such that it is one item larger than it ever was:

(swap! things into [{:x :u} {:x :v}])

;; the following is printed (because things now has 4 items, so the 3rd
;; item is now {:x :u} and the max size increases by one with the new
;; item {:x :v}):

:updating nil :u
:creating :v

A weird imagination is most useful to gain full advantage of all the features.

Takes a vector of binding-form/collection-cell pairs and one or more body
expressions, similar to clojure.core/doseq. Iterating over the collection
cells produces a sequence of items that may grow, shrink, or update over
time. Whenever this sequence grows the body expressions are evaluated (for
side effects) exactly once for each new location in the sequence. Bindings
are bound to cells that refer to the item at that location.

Consider:

    (def things (cell [{:x :a} {:x :b} {:x :c}]))

    (cell-doseq [{:keys [x]} things]
      (prn :creating @x)
      (add-watch x nil #(prn :updating %3 %4)))

    ;; the following is printed -- note that x is a cell:

    :creating :a
    :creating :b
    :creating :c

Shrink things by removing the last item:

    (swap! things pop)

    ;; the following is printed (because the 3rd item in things is now nil,
    ;; since things only contains 2 items) -- note that the doit function is
    ;; not called (or we would see a :creating message):

    :updating :c nil

Grow things such that it is one item larger than it ever was:

    (swap! things into [{:x :u} {:x :v}])

    ;; the following is printed (because things now has 4 items, so the 3rd
    ;; item is now {:x :u} and the max size increases by one with the new
    ;; item {:x :v}):

    :updating nil :u
    :creating :v

A weird imagination is most useful to gain full advantage of all the features.
sourceraw docstring

cell-doseq*cljs

(cell-doseq* c f)

Given a function f and a cell c that contains a seqable collection of items, calls f for side effects once for each item in c, passing one argument: a formula cell equivalent to (cell= (nth c i)) for the ith item in c. Whenever c grows beyond its previous maximum size f is called as above for each item beyond the maximum size. Nothing happens when c shrinks.

See also: the javelin.core/cell-doseq macro.

Consider:

(def things (cell [:a :b :c]))
(cell-doseq*
  things
  (fn doit [x]
    (prn :creating @x)
    (add-watch x nil #(prn :updating %3 %4))))

;; the following is printed:

:creating :a
:creating :b
:creating :c

Shrink things by removing the last item:

(swap! things pop)

;; the following is printed (because the 3rd item in things is now nil,
;; since things only contains 2 items) -- note that the doit function is
;; not called (or we would see a :creating message):

:updating :c nil

Grow things such that it is one item larger than it ever was:

(swap! things into [:u :v])

;; the following is printed (because things now has 4 items, so the 3rd
;; item is now :u and the max size increases by one with the new item :v):

:updating nil :u
:creating :v

A weird imagination is most useful to gain full advantage of all the features.

Given a function f and a cell c that contains a seqable collection of items,
calls f for side effects once for each item in c, passing one argument: a
formula cell equivalent to (cell= (nth c i)) for the ith item in c. Whenever
c grows beyond its previous maximum size f is called as above for each item
beyond the maximum size. Nothing happens when c shrinks.

See also: the javelin.core/cell-doseq macro.

Consider:

    (def things (cell [:a :b :c]))
    (cell-doseq*
      things
      (fn doit [x]
        (prn :creating @x)
        (add-watch x nil #(prn :updating %3 %4))))

    ;; the following is printed:

    :creating :a
    :creating :b
    :creating :c

Shrink things by removing the last item:

    (swap! things pop)

    ;; the following is printed (because the 3rd item in things is now nil,
    ;; since things only contains 2 items) -- note that the doit function is
    ;; not called (or we would see a :creating message):

    :updating :c nil

Grow things such that it is one item larger than it ever was:

    (swap! things into [:u :v])

    ;; the following is printed (because things now has 4 items, so the 3rd
    ;; item is now :u and the max size increases by one with the new item :v):

    :updating nil :u
    :creating :v

A weird imagination is most useful to gain full advantage of all the features.
sourceraw docstring

cell-letclj/smacro

(cell-let [bindings c & more] & body)
source

cell-mapcljs

(cell-map f c)

Given a function f and a cell c that contains a seqable collection of items, returns a seq of formula cells such that the ith formula cell is equivalent to (cell= (f (nth c i))).

Given a function f and a cell c that contains a seqable collection of items,
returns a seq of formula cells such that the ith formula cell is equivalent
to (cell= (f (nth c i))).
sourceraw docstring

cell=clj/smacro

(cell= expr)
(cell= expr f)
source

cell?cljs

(cell? c)

Returns c if c is a Cell, nil otherwise.

Returns c if c is a Cell, nil otherwise.
sourceraw docstring

constant?cljs

(constant? c)
source

defcclj/smacro

(defc sym expr)
(defc sym doc expr)
source

defc=clj/smacro

(defc= sym expr)
(defc= sym doc & [expr f])
source

deref*cljs

(deref* x)

If x is a Cell dereferences x and returns the value, otherwise returns x.

If x is a Cell dereferences x and returns the value, otherwise returns x.
sourceraw docstring

destroy-cell!cljs

(destroy-cell! this)
(destroy-cell! this keep-watches?)

Unlinks this Cell from the cell graph and resets all internal state. Watches are preserved when keep-watches? is true, otherwise they are all removed.

Unlinks this Cell from the cell graph and resets all internal state. Watches
are preserved when keep-watches? is true, otherwise they are all removed.
sourceraw docstring

destructure*clj

Select a version of #'destructure that works with the version of the CLJS compiler that is provided. Older versions of CLJS do not provide destructure so we fall back to using Clojure's destructure function in that case.

Select a version of #'destructure that works with the version of the CLJS
compiler that is provided. Older versions of CLJS do not provide destructure
so we fall back to using Clojure's destructure function in that case.
sourceraw docstring

dosyncclj/smacro

(dosync & body)

Evaluates the body within a Javelin transaction. Propagation of updates to formula cells is deferred until the transaction is complete. Input cells will update during the transaction. Transactions may be nested.

Evaluates the body within a Javelin transaction. Propagation of updates
to formula cells is deferred until the transaction is complete. Input
cells *will* update during the transaction. Transactions may be nested.
sourceraw docstring

dosync*cljs

(dosync* thunk)

Calls the thunk with no arguments within a transaction. Propagation of updates to formula cells is deferred until the transaction is complete. Input cells will update during the transaction. Transactions may be nested.

See also: the javelin.core/dosync macro.

Calls the thunk with no arguments within a transaction. Propagation of
updates to formula cells is deferred until the transaction is complete.
Input cells *will* update during the transaction. Transactions may be
nested.

See also: the javelin.core/dosync macro.
sourceraw docstring

extract-symsclj

(extract-syms bindings)

Extract symbols that will be bound by bindings, including autogenerated symbols produced for destructuring.

Extract symbols that will be bound by bindings, including autogenerated
symbols produced for destructuring.
sourceraw docstring

extract-syms-without-autogenclj

(extract-syms-without-autogen bindings)

Extract only the symbols that the user is binding from bindings, omitting any intermediate autogenerated bindings used for destructuring. A trick is used here taking advantage of the fact that gensym names are produced as a side effect -- successive calls to extract-syms are not redundant.

Extract only the symbols that the user is binding from bindings, omitting
any intermediate autogenerated bindings used for destructuring. A trick is
used here taking advantage of the fact that gensym names are produced as a
side effect -- successive calls to extract-syms are not redundant.
sourceraw docstring

formulacljs

(formula f)
(formula f updatefn)

Returns a function that returns a formula cell with f as its formula, and if updatefn is provided the returned cell is a lens.

See also: the javelin.core/cell= macro.

(def x (cell 100))
(def y (cell 200))

(def z1 (cell= (+ x y)))
(def z2 ((formula +) x y))

The formula cells z1 and z2 are equivalent.

Returns a function that returns a formula cell with f as its formula, and
if updatefn is provided the returned cell is a lens.

See also: the javelin.core/cell= macro.

    (def x (cell 100))
    (def y (cell 200))

    (def z1 (cell= (+ x y)))
    (def z2 ((formula +) x y))

The formula cells z1 and z2 are equivalent.
sourceraw docstring

formula-ofclj/smacro

(formula-of deps & body)

ALPHA: this macro may change.

Given a vector of dependencies and one or more body expressions, emits a form that will produce a formula cell. The dependencies must be names that will be re-bound to their values within the body. No code walking is done. The value of the formula cell is computed by evaluating the body expressions whenever any of the dependencies change.

Note: the dependencies need not be cells.

E.g. (def x 100) (def y (cell 200)) (def z (cell= (inc y)))

(def c (formula-of [x y z] (+ x y z)))

(deref c) ;=> 501

(swap! y inc)
(deref c) ;=> 503
ALPHA: this macro may change.

Given a vector of dependencies and one or more body expressions, emits a
form that will produce a formula cell. The dependencies must be names that
will be re-bound to their values within the body. No code walking is done.
The value of the formula cell is computed by evaluating the body expressions
whenever any of the dependencies change.

Note: the dependencies need not be cells.

E.g.
    (def x 100)
    (def y (cell 200))
    (def z (cell= (inc y)))

    (def c (formula-of [x y z] (+ x y z)))

    (deref c) ;=> 501

    (swap! y inc)
    (deref c) ;=> 503
sourceraw docstring

formula?cljs

(formula? c)
source

formuletclj/smacro

(formulet bindings & body)

ALPHA: this macro may change.

Given a vector of binding-form/dependency pairs and one or more body expressions, emits a form that will produce a formula cell. Each binding form is bound to the value of the corresponding dependency within the body. No code walking is done. The value of the formula cell is computed by evaluating the body expressions whenever any of the dependencies change.

Note: the depdendency expressions are evaluated only once, when the formula cell is created, and they need not evaluate to javelin cells.

E.g. (def a (cell 42)) (def b (cell {:x 100 :y 200}))

(def c (formulet [v (cell= (inc a))
                  w (+ 1 2)
                  {:keys [x y]} b]
          (+ v w x y)))

(deref c) ;=> 346

(swap! a inc)
(deref c) ;=> 347
ALPHA: this macro may change.

Given a vector of binding-form/dependency pairs and one or more body
expressions, emits a form that will produce a formula cell. Each binding
form is bound to the value of the corresponding dependency within the body.
No code walking is done. The value of the formula cell is computed by
evaluating the body expressions whenever any of the dependencies change.

Note: the depdendency expressions are evaluated only once, when the formula
cell is created, and they need not evaluate to javelin cells.

E.g.
    (def a (cell 42))
    (def b (cell {:x 100 :y 200}))

    (def c (formulet [v (cell= (inc a))
                      w (+ 1 2)
                      {:keys [x y]} b]
              (+ v w x y)))

    (deref c) ;=> 346

    (swap! a inc)
    (deref c) ;=> 347
sourceraw docstring

hoistclj

(hoist x env)
source

hoist?clj

(hoist? x local)
source

input?cljs

(input? c)
source

lenscljs

(lens c f)

Returns a new lens whose value is the same as c's with update function f. This is equivalent to ((formula identity f) c).

Returns a new lens whose value is the same as c's with update function f.
This is equivalent to ((formula identity f) c).
sourceraw docstring

lens?cljs

(lens? c)
source

liftcljsdeprecated

This function is deprecated, please use #'javelin.core/formula instead.

This function is deprecated, please use #'javelin.core/formula instead.
sourceraw docstring

macroexpand*clj

(macroexpand* env form)

Expand form if it is a CLJS macro, otherwise just return form.

Expand form if it is a CLJS macro, otherwise just return form.
sourceraw docstring

macroexpand-allclj/smacro

(macroexpand-all form)

Fully expand all CLJS macros contained in form.

Fully expand all CLJS macros contained in form.
sourceraw docstring

macroexpand-all*clj

(macroexpand-all* env form)

Fully expand all CLJS macros contained in form.

Fully expand all CLJS macros contained in form.
sourceraw docstring

mxclj/smacro

(mx form)

Expand all macros in form and pretty-print them (as code).

Expand all macros in form and pretty-print them (as code).
sourceraw docstring

mx2clj/smacro

(mx2 form)

Expand all macros in form and pretty-print them (as data).

Expand all macros in form and pretty-print them (as data).
sourceraw docstring

prop-cellclj/smacro

(prop-cell prop)
(prop-cell prop setter & [callback])
source

set-cell!cljs

(set-cell! c x)

Converts c to an input cell in place, setting its contents to x. It's okay if c was already an input cell. Changes will be propagated to any cells that depend on c.

Converts c to an input cell in place, setting its contents to x. It's okay
if c was already an input cell. Changes will be propagated to any cells that
depend on c.
sourceraw docstring

set-cell!=clj/smacro

(set-cell!= c expr)
(set-cell!= c expr updatefn)
source

set-formula!cljs

(set-formula! this)
(set-formula! this f)
(set-formula! this f sources)
(set-formula! this f sources updatefn)

Given a Cell and optional formula function f and the cells f depends on, sources, updates the formula for this cell in place. If f and/or sources is not spcified they are set to nil.

Given a Cell and optional formula function f and the cells f depends on,
sources, updates the formula for this cell in place. If f and/or sources
is not spcified they are set to nil.
sourceraw docstring

unsupp?clj

(unsupp? x local)
source

walkclj

(walk x local)
source

walk-bind1clj

(walk-bind1 [sym bindings & body] local)
source

walk-bind2clj

(walk-bind2 [sym bindings & body] local)
source

walk-bind3clj

(walk-bind3 [sym & arities] local)
source

walk-catchclj

(walk-catch [sym etype bind & body] local)
source

walk-dotclj

(walk-dot [sym obj meth & more] local)
source

walk-finallyclj

(walk-finally [sym & body] local)
source

walk-listclj

(walk-list x local)
source

walk-mapclj

(walk-map x local)
source

walk-passthruclj

(walk-passthru x local)
source

walk-seqclj

(walk-seq x local)
source

walk-symclj

(walk-sym x local)
source

walk-tryclj

(walk-try [sym & body] local)
source

with-letclj/smacro

(with-let [binding resource] & body)

Binds resource to binding and evaluates body. Then, returns resource. It's a cross between doto and with-open.

Binds resource to binding and evaluates body.  Then, returns
resource.  It's a cross between doto and with-open.
sourceraw docstring

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

× close