• Stars
    star
    184
  • Rank 209,187 (Top 5 %)
  • Language
    Clojure
  • License
    Other
  • Created over 12 years ago
  • Updated about 11 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Automatic state propogation in ClojureScript

Reflex

Reflex is a ClojureScript library for automatic state propagation. Intrinsic application state lives in atoms, from which derived values can be computed using Reflex-provided "computed observables" (COs). COs always reflect the latest state, can depend on multiple atoms, and are themselves watchable (i.e., you can chain them). COs are lazily evaluated, computing state only when they are dereferenced---they will notify their watches when they become dirty, but will not pass any values.

(def a (atom 1))
(def b (computed-observable (inc @a)))
@b ;;=> 2
(reset! a 2)
@b ;;=> 3

To use from ClojureScript add this to your project.clj:

[com.keminglabs/reflex "0.1.1"]

Implementation

Reflex monitors dereferencing of ClojureScript atoms to determine the atoms that each computed observerable depends on. When any of these atoms change, the dependent CO is marked as dirty. COs are lazy; their values will be calculated only when the CO is dereferenced (and only then if it dirty; otherwise the cached value is used).

Dependencies are recalculated every time the CO function is run, which means that dependencies can vary. E.g., if atom a is truthy, then computed observable

(computed-observable (if @a @b @c))

will depend only on a and b. If, later, a becomes falsey, then the CO would be updated to depend only on a and c.

Thanks

Big hat tip to Knockout.js folks. Not only did they write great code, they also took the time to write illuminating technical prose!

More Repositories

1

c2

Declarative data visualization in Clojure(Script).
JavaScript
643
star
2

cljx

Write a portable codebase targeting Clojure/ClojureScript
Clojure
398
star
3

subform-layout

Embeddable layout engine. Like flexbox, but with fewer concepts, applied uniformly.
191
star
4

zmq-async

Threadsafe Clojure core.async interface to ZeroMQ
Clojure
167
star
5

vagrant-ec2

Use the same chef to provision Vagrant VMs and EC2 instances
Ruby
166
star
6

sandboxtron

Shell
130
star
7

jetty7-websockets-async

Clojure core.async interface to Jetty7's websockets.
Clojure
107
star
8

cljs-d3

A ClojureScript faรงade for the D3 JavaScript DOM-manipulation library
Clojure
85
star
9

todoFRP

Functional reactive todo lists
JavaScript
81
star
10

singult

JavaScript Hiccup compiler
CoffeeScript
51
star
11

cljs-react-perf

Performance experiments w/ CLJS React libraries and techniques.
Clojure
40
star
12

json-tagged-literals

More palatable JSON serialization
CoffeeScript
40
star
13

c2-demos

Example C2 visualizations and applications
Clojure
37
star
14

svd2zig

Generate Zig API from SVD register definitions.
Zig
36
star
15

clj-liblinear

A Clojure wrapper for LIBLINEAR, a linear support vector machine library
Clojure
28
star
16

cassowary-coffee

CoffeeScript port of the Cassowary linear constraint solver
CoffeeScript
24
star
17

hicada

A cljs hiccup compiler that helps you be deliberate about runtime interpretation.
Clojure
21
star
18

touchtron

Rust touchpad / usb experiments
Rust
16
star
19

clojurescript-compiler-proposal

Request for comments on ClojureScript compiler interface updates
Clojure
14
star
20

cljs-chosen

ClojureScript interface to Harvest's Chosen <select> library
JavaScript
12
star
21

tidy-codebase-starter-kit

Shell
9
star
22

vomnibus

Assortment of useful geographic data, color schemes, &c.
Clojure
8
star
23

vcf

Genetic variant analysis tool.
JavaScript
8
star
24

YALL1

All your sparse bases are belong to us.
Objective-C
8
star
25

lorax

Provably efficient deep learning
Clojure
5
star
26

prote.cs

Compressed sensing based protein fold search
JavaScript
4
star
27

denizen-demo-compojure

Demo Clojure web app using Denizen for user management
Clojure
4
star
28

question-rust-inlining

A question about inlining and match vs lookup tables in Rust.
LLVM
4
star
29

Rliblinear

R interface to LIBLINEAR, a linear support vector machine library
C++
3
star
30

cljs-hiccup-inference

Minimal example repo of a CLJS Hiccup->React compiler w/ type inference
Clojure
3
star
31

splot

Rust
2
star
32

question-rust-websocket

Rust
2
star
33

profile-cljs

Wherein I examine ClojureScript performance.
Clojure
2
star
34

datomic-fuse-AOT

A hellscape of Clojure+Datomic lazy loading errors.
Clojure
1
star
35

eui

Rust
1
star