Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 273a04a
Showing
7 changed files
with
162 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
pom.xml | ||
*jar | ||
lib | ||
classes | ||
.lein-deps-sum | ||
.lein-repl-history | ||
.lein-plugins/ | ||
*iml | ||
.lein-env | ||
out | ||
target | ||
.nrepl-port | ||
.nrepl-history | ||
.repl/ | ||
repl/ | ||
private | ||
figwheel_server.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# sytac-core-async | ||
Slides and code for presentation at the [DevJam meetup](http://www.meetup.com/Sytac-Dev-Jam/events/223330464/), July 29 2015. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Animals CRUD | ||
|
||
## Running the project | ||
|
||
In a terminal, start the web server: | ||
|
||
lein repl | ||
(start-server) | ||
|
||
In another terminal, start figwheel: | ||
|
||
lein figwheel | ||
|
||
Finally browse to | ||
[http://localhost:8080/index.html](http://localhost:8080/index.html) | ||
and have fun. | ||
|
||
## License | ||
|
||
Copyright Michiel Borkent | ||
|
||
Distributed under the Eclipse Public License either version 1.0 or (at | ||
your option) any later version. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<html> | ||
<head> | ||
</head> | ||
<body> | ||
<script src="main.js" type="text/javascript"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
if(typeof goog == "undefined") document.write('<script src="out/goog/base.js"></script>'); | ||
document.write('<script src="out/cljs_deps.js"></script>'); | ||
document.write('<script>if (typeof goog != "undefined") { goog.require("cljs_demo.main"); } else { console.warn("ClojureScript could not load :main, did you forget to specify :asset-path?"); };</script>'); | ||
|
||
document.write("<script>if (typeof goog != \"undefined\") { goog.require(\"figwheel.connect\"); }</script>"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
(defproject cljs-demo "0.1.0-SNAPSHOT" | ||
:description "FIXME: write this!" | ||
:url "http://example.com/FIXME" | ||
:dependencies [[org.clojure/clojure "1.7.0"] | ||
[org.clojure/clojurescript "0.0-3308"] | ||
[org.clojure/core.async "0.1.346.0-17112a-alpha"] ] | ||
|
||
:plugins [[lein-cljsbuild "1.0.5"] | ||
[lein-figwheel "0.3.1"]] | ||
|
||
:clean-targets ^{:protect false} [:target-path :compile-path "out"] | ||
|
||
:cljsbuild {:builds [{:id "sytac" | ||
:source-paths ["src"] | ||
:figwheel true | ||
:compiler {:output-to "main.js" | ||
:output-dir "out" | ||
:optimizations :none | ||
:asset-path "out" | ||
:main "cljs-demo.main" | ||
:source-map true}}]} | ||
|
||
:global-vars {*print-length* 20}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
(ns cljs-demo.main | ||
(:require-macros [cljs.core.async.macros :refer (go)]) | ||
(:require | ||
[cljs.core.async :refer (<!)])) | ||
|
||
(enable-console-print!) | ||
|
||
;; (defn f [x] | ||
;; (inc x)) | ||
|
||
;; (defn f [x] | ||
;; (if (odd? x) x | ||
;; (inc x))) | ||
|
||
;; (defn f [x] | ||
;; (set! x "bar")) | ||
|
||
;; (def foo (js-obj "bar" "baz")) | ||
;; (set! (.-bar foo) "baaz") | ||
;; (aset foo "abc" 17) | ||
|
||
;; (js/alert "foo") | ||
;; (.getTime (js/Date.)) | ||
;; (.. (js/Date.) (getTime) (toString)) | ||
|
||
;; ;; vectors | ||
;; (def v [1 2 3]) | ||
;; (conj v 4) | ||
;; (get v 0) | ||
;; (v 0) | ||
|
||
;; ;; hash maps | ||
;; (def m {:foo 1 :bar 2}) | ||
;; (assoc m :foo 2) | ||
;; (get m :foo) | ||
;; (m :foo) | ||
;; (:foo m) | ||
;; (dissoc m :foo) | ||
|
||
;; ;; functional programming | ||
;; (def numbers (range 10)) | ||
;; (filter odd? numbers) | ||
;; (map inc numbers) | ||
;; (reduce + numbers) | ||
;; (reductions + numbers) | ||
|
||
;; ;; sequences | ||
;; (first [1 2 3]) | ||
;; (rest [1 2 3]) | ||
;; (distinct [1 1 2 3]) | ||
;; (take 2 (range 10)) | ||
|
||
;; ;; lazy sequences | ||
;; (take 2 (map | ||
;; (fn [n] (js/alert n) n) | ||
;; (range))) | ||
|
||
;; ;; atoms/mutable state | ||
;; (def my-atom (atom 0)) | ||
;; @my-atom | ||
;; (reset! my-atom 1) | ||
;; (reset! my-atom (inc @my-atom)) | ||
;; (swap! my-atom (fn [old-value] | ||
;; (inc old-value))) | ||
;; (swap! my-atom inc) | ||
;; @my-atom | ||
|
||
;; ;; macros | ||
;; (map inc | ||
;; (filter odd? | ||
;; (range 10))) | ||
|
||
;; (->> | ||
;; (range 10) | ||
;; (filter odd?) | ||
;; (map inc)) | ||
|
||
;; (macroexpand | ||
;; '(->> (range 10) (filter odd?))) | ||
|
||
;; (macroexpand | ||
;; '(->> (range 10) | ||
;; (filter odd?) | ||
;; (map inc))) |