Skip to content

Latest commit

 

History

History
61 lines (46 loc) · 2.07 KB

README.org

File metadata and controls

61 lines (46 loc) · 2.07 KB

Entangle

Two atoms, separated both in space and time can be bound together using entanglement.

Entangle is an implementation of Neil Fraser’s Differential Sync algorithm using core.async for Clojure and Clojurescript. It currently depends on a forked version of clj-diff (for Clojure & Clojurescript cross compatibility).

Usage

(require ['entagle.core :as e]
         ['clojure.core.async :as a])

(def atom-a (atom ""))
(def atom-b (atom ""))

(def a<-b (a/chan))
(def a->b (a/chan))

(e/start-sync atom-a a<-b a->b :atom-a)
(e/start-sync atom-b a->b a<-b :atom-b)

(reset! atom-a "FOO")

; some time later
(= @atom-b "FOO)
;=> true

Motivation

How hard would it be to create a library that performed synchronization of state in the background? This sounds very useful for real-time collaborative web applications. Building this for Clojure seems really useful because it can target both client and server.

Clojure provides alot of interesting features which make building this type of functionality easier. In particular:

Reference Types
Clojure reference types like atom provide an excellent abstraction for working with state. Watches work transparently and developers work with synchronization using reset! and update! as usual. This is essentially the Observer Pattern in the standard library.
Write Once, Run Everywhere
Clojure/Script targets more than the JVM which is useful when working on web application clients that run in Javascript
CSP style semantics
This library is heavily event-driven, and core.async makes modelling event loops simpler. It’s lightweight concurrency also abstracts away the lack of threading in Javascript.

Building

Standalone Build

lein with-profile uberjar uberjar

License

Copyright © 2015 rymndhng

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.