Back

<! (clj)

(source)

function

(<! port)
takes a val from port. Must be called inside a (go ...) block. Will return nil if closed. Will park if nothing is available. Returns true unless port is already closed

Examples

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]]))

  (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))))
dvcrn/markright
(ns markright.ui
  (:require-macros [cljs.core.async.macros :refer [go go-loop]])
  (:require [om.next :as om :refer-macros [defui]]
            [om.dom :as dom :include-macros true]
            [goog.dom :as gdom]
            [markright.parser :as p]
            [electron.ipc :as ipc]
            [markright.components.codemirror :as cm]
            [markright.components.markdown :as md]
            [cljs.core.async :as async :refer [chan put! pub sub unsub <!]]))

(defui RootComponent
  static om/IQuery
  (query [this]
    '[:app/text :app/force-overwrite :app/filepath :app/saved-text])
  Object
  (componentDidMount [this]
                   ;; tell the backend that a frontend is now loaded
                   (ipc/cast :init-frontend {})
                   (go
                       ;; since the backend could have already opened a file while the ui loads
                       ;; we are going to ask it if this was the case
                       (let [backend-state (<! (ipc/call :backend-state {}))]
                         (if (not (nil? (backend-state :content)))
                           (om/transact! this `[(app/load-content {:content ~(backend-state :content)
                                                                   :filepath ~(backend-state :filepath)})])))

                     ;; super mega hack
                     ;; FIXME: remove me
                     (go-loop []
                       (let [fx (<! p/root-channel)]
                         (fx this))
                       (recur))))
  (componentWillMount [this] (.setOptions js/marked #js {:gfm true}))
  (componentWillReceiveProps [this next-props])
  (render [this]
    (let [{:keys [app/text app/html app/force-overwrite app/filepath app/saved-text]} (om/props this)]
      (if (not (= 0 (.-length filepath)))
        (if (= text saved-text)
          (set! (.-title js/document) filepath)
          (set! (.-title js/document) (str "* " filepath))))
wilkerlucio/pathom
(ns com.wsscode.common.async-cljs
  "DEPRECATED: please use com.wsscode.async.async-cljs instead"
  (:require
    [cljs.core.async :as async]))

(defmacro <!p [promise]
  `(consumer-pair (cljs.core.async/<! (promise->chan ~promise))))

(defmacro <? [ch]
  `(throw-err (cljs.core.async/<! ~ch)))

       (promise? res#)
       (<!p res#)

(defmacro <!maybe [x]
  `(let [res# ~x]
     (if (chan? res#) (cljs.core.async/<! res#) res#)))

(defmacro let-chan*
  "Like let-chan, but async errors will be returned instead of propagated"
  [[name value] & body]
  `(let [res# ~value]
     (if (chan? res#)
       (go-catch
         (let [~name (cljs.core.async/<! res#)]
           ~@body))
       (let [~name res#]
         ~@body))))
typedclojure/typedclojure
    buffer
      use buffer> (similar for other buffer constructors)
    "}
  ^:no-doc
  typed.lib.cljs.core.async
  (:require-macros [cljs.core.typed :refer [ann ann-datatype defalias ann-protocol inst
                                            tc-ignore]
                    :as t])
  (:require [cljs.core.typed :refer [AnyInteger Seqable]]
            [cljs.core.async]))

(ann ^:no-check cljs.core.async/<!! (All [x] [(ReadOnlyPort x) -> (U nil x)]))
(ann ^:no-check cljs.core.async/>!! (All [x] [(WriteOnlyPort x) x -> nil]))
(ann ^:no-check cljs.core.async/alts!! 
     (All [x d]
          (Fn [(Seqable (U (Port x) '[(Port x) x])) (Seqable (Port x)) & :mandatory {:default d} :optional {:priority (U nil true)} -> 
               (U '[d ':default] '[(U nil x) (Port x)])]
              [(Seqable (U (Port x) '[(Port x) x])) & :optional {:priority (U nil true)} -> '[(U nil x) (Port x)]])))
astashov/tixi
(ns tixi.core
  (:require-macros [tixi.controller :refer (render)]
                   [cljs.core.async.macros :refer [go]])
  (:require [tixi.channel :refer [channel]]
            [tixi.data :as d]
            [tixi.dispatcher :as di]
            [cljs.reader :as r]
            [tixi.sync :as s]
            [tixi.compress :as c]
            [tixi.mutators.shared :as ms]
            [tixi.utils :refer [p]]
            [cljs.core.async :as async :refer [<!]]))

(go (while true
  (di/handle-input-event (<! channel))))