Back
go (clj)
(source)variable
Examples
viebel/klipse
;; core.async
(ns my.async
(:require-macros [cljs.core.async.macros :refer [go]])
(:require [cljs.core.async :refer [timeout <! chan put!]]))
(go
(print 8)
(print 9999))
;; gist
(ns my.async
(:require [viebel.gist-368d3bec58d3ec47e935ad488bafb600.raw.color])) ; https://gist.github.com/viebel/368d3bec58d3ec47e935ad488bafb600
;; gist in url param
http://localhost:5014/index-dbg.html?cljs_in.gist=viebel/368d3bec58d3ec47e935ad488bafb600&eval_only=1
bhauman/devcards
(ns devdemos.testing
(:require
[devcards.core :as devcards]
[cljs.test :as t :refer [report] :include-macros true]
[sablono.core :as sab]
[cljs.core.async :refer [<! timeout]])
(:require-macros
[cljs.core.async.macros :refer [go]]
[devcards.core :as dc :refer [defcard defcard-doc]]
[cljs.test :refer [is testing async]]))
The following is an example of using `devcards.core/deftest`
"
(dc/mkdn-pprint-code
'(deftest first-testers
"## This is documentation
It should work well"
(testing "good stuff"
(is (= (+ 3 4 55555) 5) "Testing the adding")
(is (= (+ 1 0 0 0) 1) "This should work")
(is (= 1 3))
(is false)
(is (throw "heck"))
(is (js/asdf)))
"## And here is more documentation"
(testing "bad stuff"
(is (= (+ 1 0 0 0) 1))
(is (= (+ 3 4 55555) 4))
(is false)
(testing "mad stuff"
(is (= (+ 1 0 0 0) 1))
(is (= (+ 3 4 55555) 4))
(is false)))))
(dc/deftest first-testers
"## This is documentation
It should work well"
(testing "good stuff"
(is (= (+ 3 4 55555) 5) "Testing the adding")
(is (= (+ 1 0 0 0) 1) "This should work")
(is (= 1 3))
(is false)
(is (throw "heck"))
(is (js/asdf)))
"## And here is more documentation"
(testing "bad stuff"
(is (= (+ 1 0 0 0) 1))
(is (= (+ 3 4 55555) 4))
(is false)
(testing "mad stuff"
(is (= (+ 1 0 0 0) 1))
(is (= (+ 3 4 55555) 4))
(is false))))
(t/testing "Let's run async tests!"
(is (= (+ 3 4 55555) 4) "Testing the adding")
(is (= (+ 1 0 0 0) 1) "This should work")
(is (= 1 3))
(is true)
(async done
(go
(<! (timeout 100))
(is (= (+ 3 4 55555) 4) "Testing the adding")
(is (= (+ 1 0 0 0) 1) "This should work")
(is (throw "heck")) ;; all the tests from here down
;; will not be rendered
(is (= 1 3))
(is true)
(done))))
"## And here is more documentation"
(t/testing "bad stuff"
(is (= (+ 1 0 0 0) 1))
(t/is (= (+ 3 4 55555) 4))
(t/is false)
(t/testing "mad stuff"
(is (= (+ 1 0 0 0) 1))
(t/is (= (+ 3 4 55555) 4))
(t/is false))))
nvbn/textarea-to-code-editor
(ns textarea-to-code-editor.content.handlers
(:require-macros [cljs.core.async.macros :refer [go]]
[textarea-to-code-editor.macros :refer [defhandler]])
(:require [cljs.core.match :refer-macros [match]]
[cljs.core.async :refer [>!]]
[textarea-to-code-editor.content.editor :as e]))
(defhandler populate-context-menu!
"Populates context menu with available modes."
[el runtime-chan]
(go (>! runtime-chan [:populate-context-menu
{:current-mode (e/get-editor-mode el)
:modes (e/get-modes)}]))
el)
(defhandler clear-context-menu!
"Clears context menu."
[runtime-chan]
(go (>! runtime-chan [:clear-context-menu nil]))
nil)
jarohen/oak
(ns oak.http
(:require [oak.core :as oak]
[cljs-http.client :as http]
[cljs.core.async :as a])
(:require-macros [cljs.core.async.macros :refer [go]]))
(defmethod oak/cmd! ::request! [{:keys [method url ev] :as opts} cb]
(go
(let [{:keys [success] :as resp} (a/<! (http/request (dissoc opts :ev)))]
(when-let [[ev-type ev-args] ev]
(cb [ev-type (merge ev-args
{::resp (dissoc resp :success)
::success? success})])))))
Beyamor/ruin
(ns demo.core
(:use [demo.play-scene :only [play-scene]]
[cljs.core.async :only [<! chan]]
[ruin.scene :only [defscene]])
(:require [ruin.display :as d]
[ruin.game :as g]
[ruin.scene :as s]
[demo.entities :as es]
[demo.tiles :as tiles]
[ruin.generate :as generate])
(:use-macros [cljs.core.async.macros :only [go]])
(:require-macros [lonocloud.synthread :as ->]))
:go
(fn [{:keys [key-events] :as game}]
(go (loop [[event-type key-code] (<! key-events)]
(if (and (= event-type :down)
(= key-code js/ROT.VK_RETURN))
(g/change-scene game :play)
(recur (<! key-events))))))})
:go
(fn [_] (chan))})