All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.indoles.clj.state_chan.clj Maven / Gradle / Ivy

The newest version!
(ns com.indoles.clj.state-chan
  (:require [clojure.core.async :as async]))

(defn init
  ([ch init-state]
     (async/go-loop [req ch
                     state init-state
                     item (async/! ch
                         (if modified
                           msg
                           (fn [item] (let [n (msg item)]
                                       item))))))
  ([ch msg]
     (send-msg ch msg true)))

(defn receive-msg [ch]
  (async/! rep-ch ret))
                           ret))
               modified)
     (receive-msg rep-ch))
  ([ch rep-ch f]
     (respond-to ch rep-ch f true))
  ([ch f]
     (let [rep-ch (async/chan)
           ret (respond-to ch rep-ch f)]
       (async/close! rep-ch)
       ret)))

(defn state [ch]
  (respond-to ch identity))




© 2015 - 2025 Weber Informatics LLC | Privacy Policy