GithubHelp home page GithubHelp logo

entangle's Introduction

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.

entangle's People

Contributors

rymndhng avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.