Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

cljs 0.0-2173 compat: IReset/ISwap support in Cell

- Cell type works with cljs 0.0-2173 swap! and reset! functions
- Backward compatible to at least 0.0-2138 (with warnings)
- reset! performance appears comparable to previous releases
  • Loading branch information...
commit 11560e4f1031ea9f425fe9d70725b7c3c2cd115b 1 parent 2601c71
@alandipert alandipert authored
Showing with 16 additions and 2 deletions.
  1. +2 −2 project.clj
  2. +14 −0 src/tailrecursion/javelin.cljs
View
4 project.clj
@@ -1,4 +1,4 @@
-(defproject tailrecursion/javelin "3.1.0"
+(defproject tailrecursion/javelin "3.1.1"
:description "A Functional Reactive Programming library for ClojureScript"
:url "https://github.com/tailrecursion/javelin"
:license {:name "Eclipse Public License"
@@ -10,7 +10,7 @@
:repl-options {:init-ns tailrecursion.javelin}
:profiles {:devz {:plugins [[lein-cljsbuild "0.3.2"]
[com.cemerick/clojurescript.test "0.1.0"]]
- :dependencies [[org.clojure/clojurescript "0.0-2138"]]}}
+ :dependencies [[org.clojure/clojurescript "0.0-2173"]]}}
:cljsbuild {:builds
{:test
{:source-paths ["src" "test"]
View
14 src/tailrecursion/javelin.cljs
@@ -77,6 +77,20 @@
cljs.core/IDeref
(-deref [this] (.-state this))
+ cljs.core/IReset
+ (-reset! [this new-value]
+ (let [old-value (.-state this)]
+ (set! (.-state this) new-value)
+ (when-not (nil? (.-watches this))
+ (-notify-watches this old-value new-value))
+ new-value))
+
+ cljs.core/ISwap
+ (-swap! [this f] (reset! this (f (.-state this))))
+ (-swap! [this f a] (reset! this (f (.-state this) a)))
+ (-swap! [this f a b] (reset! this (f (.-state this) a b)))
+ (-swap! [this f a b xs] (reset! this (apply f (.-state this) a b xs)))
+
cljs.core/IWatchable
(-notify-watches [this oldval newval]
(doseq [[key f] watches] (f key this oldval newval)))
Please sign in to comment.
Something went wrong with that request. Please try again.