This commit is contained in:
Dan Holmsand 2015-07-30 19:25:08 +02:00
commit f00ca03f70
12 changed files with 66 additions and 44 deletions

View File

@ -15,11 +15,11 @@ run: figwheel
# development build with auto-reloading and site generation
runsite:
@$(MAKE) run PROF=dev,site,$(PROF)
@$(MAKE) run PROF=+site,$(PROF)
# development build with figwheel, but no tests
runnotest:
@$(MAKE) run PROF=dev-notest,$(PROF)
@$(MAKE) run PROF=+dev-notest,$(PROF)
# production build with auto-rebuild
runprod: clean

View File

@ -8,7 +8,9 @@ var run = function (src) {
vm.runInThisContext(fs.readFileSync(src), src);
}
var loadSrc = function (mainFile, outputDir, devModule) {
var imported = {};
var loadSrc = function (mainFile, outputDir, devFile) {
var googDir = path.join(outputDir, "goog");
var optNone = false;
if (outputDir) {
@ -21,13 +23,16 @@ var loadSrc = function (mainFile, outputDir, devModule) {
}
global.CLOSURE_IMPORT_SCRIPT = function (src) {
var s = path.resolve(path.resolve(cwd, path.join(googDir, src)));
run(s);
return true;
if (!(s in imported)) {
imported[s] = true;
run(s);
return true;
}
};
run(path.join(googDir, "base.js"));
run(path.join(outputDir, "cljs_deps.js"));
goog.require(devModule);
run(path.join(outputDir, devFile));
} else {
run(mainFile);
}

View File

@ -3,7 +3,7 @@ var cljsLoad = require("./cljs-load");
var srcFile = "outsite/public/js/main.js";
var outputDirectory = "outsite/public/js/out/";
var moduleName = "reagentdemo.dev";
var devFile = "reagentdemo/dev.js";
var beep = "\u0007";
@ -15,7 +15,7 @@ if (typeof location === "undefined") {
var gensite = function () {
console.log("Loading " + srcFile);
var optNone = cljsLoad.load(srcFile, outputDirectory, moduleName);
var optNone = cljsLoad.load(srcFile, outputDirectory, devFile);
sitetools.core.genpages({"opt-none": optNone});
}

View File

@ -1,4 +1,4 @@
(ns ^:figwheel-always reagentdemo.core
(ns reagentdemo.core
(:require [reagent.core :as reagent :refer [atom]]
[reagent.interop :as i :refer-macros [.' .!]]
[clojure.string :as string]
@ -39,6 +39,9 @@
[tools/page-content]
[github-badge]])
(tools/start! {:body [#'demo]
:css-infiles ["site/public/css/examples.css"
"site/public/css/main.css"]})
(defn init! []
(tools/start! {:body [#'demo]
:css-infiles ["site/public/css/examples.css"
"site/public/css/main.css"]}))
(init!)

View File

@ -1,9 +0,0 @@
(ns reagentdemo.dev
(:require [reagentdemo.core]
[reagenttest.runtests]
[reagent.core :as r]
[figwheel.client :as fw]))
(when r/is-client
(fw/start
{:websocket-url "ws://localhost:3449/figwheel-ws"}))

View File

@ -3,11 +3,11 @@
:license {:name "MIT"}
:description "A simple ClojureScript interface to React"
:dependencies [[org.clojure/clojure "1.6.0"]
[org.clojure/clojurescript "0.0-2816"]
[cljsjs/react "0.12.2-5"]]
:dependencies [[org.clojure/clojure "1.7.0-RC1"]
[org.clojure/clojurescript "0.0-3308"]
[cljsjs/react "0.13.3-0"]]
:plugins [[lein-cljsbuild "1.0.4"]
:plugins [[lein-cljsbuild "1.0.6"]
[codox "0.8.12"]]
:source-paths ["src"]
@ -19,16 +19,16 @@
{:builds {:client {:source-paths ["test"]}}}}
:dev [:test
{:dependencies [[figwheel "0.2.3-SNAPSHOT"]]
:plugins [[lein-figwheel "0.2.3-SNAPSHOT"]]
{:dependencies [[figwheel "0.3.3"]]
:plugins [[lein-figwheel "0.3.3"]]
:source-paths ["demo"] ;; for lighttable
:resource-paths ["site" "outsite"]
:figwheel {:css-dirs ["site/public/css"]}
:cljsbuild
{:builds
{:client
{:source-paths ["env/dev"]
:compiler {:main "reagentdemo.dev"
{:figwheel {:on-jsload "reagenttest.runtests/reload"}
:compiler {:main "reagenttest.runtests"
:source-map true
:source-map-timestamp true
:optimizations :none

View File

@ -1,3 +1,3 @@
(ns reagent.debug)
(ns reagent.debug
(:require-macros [reagent.debug]))
;; Empty file, to allow require with :refer-macros

View File

@ -1,3 +1,2 @@
(ns reagent.interop)
;; Empty
(ns reagent.interop
(:require-macros [reagent.interop]))

View File

@ -1,4 +1,5 @@
(ns reagent.ratom)
(ns reagent.ratom
(:refer-clojure :exclude [run!]))
(defmacro reaction [& body]
`(reagent.ratom/make-reaction

View File

@ -1,8 +1,8 @@
(ns reagent.ratom
(:refer-clojure :exclude [atom])
(:require-macros [reagent.debug :refer (dbg log warn dev?)]
reagent.ratom)
(:require [reagent.impl.util :as util]))
(:require-macros [reagent.ratom])
(:require [reagent.impl.util :as util]
[reagent.debug :refer-macros [dbg log warn dev?]]))
(declare ^:dynamic *ratom-context*)
@ -241,7 +241,7 @@
IComputedImpl
(-handle-change [this sender oldval newval]
(when (and active? (not dirty?) (not (identical? oldval newval)))
(when (and active? (not (identical? oldval newval)))
(set! dirty? true)
((or auto-run run) this)))

View File

@ -1,4 +1,4 @@
(ns ^:figwheel-always reagenttest.runtests
(ns reagenttest.runtests
(:require [reagenttest.testreagent]
[reagenttest.testcursor]
[reagenttest.testinterop]
@ -44,7 +44,14 @@
(js/setTimeout all-tests 100)
(all-tests)))
(when (some? (test/deftest empty-test))
;; Only run with :load-tests true
(reset! demo/test-results [#'test-output-mini])
(run-tests))
(defn init! []
(when (some? (test/deftest empty-test))
;; Only run with :load-tests true
(reset! demo/test-results [#'test-output-mini])
(run-tests)))
(defn reload []
(demo/init!)
(init!))
(init!)

View File

@ -426,3 +426,19 @@
(swap! a update-in [:b] inc)
(is (= 4 (swap! b inc)))
(is (= 4 @b))))
(deftest test-double-reset
(let [a (r/atom {:foo {:active? false}})
c (r/cursor a [:foo])
f (fn []
(swap! c assoc :not-pristine true)
(swap! a update-in [:foo :active?] not))
spy (atom nil)
r (run!
(reset! spy (:active? @c)))]
(is (= @spy false))
(f)
(is (= @spy true))
(f)
(is (= @spy false))
(dispose r)))