Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit fe68770

Browse files
committed
Added namespace albums-stream
1 parent 3350c47 commit fe68770

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

‎src/icw/async/albums_stream.clj

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
;; [[file:~/github/intermediate-clojure-workshop/content/async/albums_stream.org::*Preamble][Preamble:1]]
2+
(ns icw.async.albums-stream
3+
(:require [clojure.core.async :as a
4+
:refer [chan go go-loop <! >! take! put!]]
5+
[icw.async.rlsc :as rlsc]
6+
[icw.data.gen :as data-gen]))
7+
;; Preamble:1 ends here
8+
9+
;; [[file:~/github/intermediate-clojure-workshop/content/async/albums_stream.org::*Outline][Outline:2]]
10+
(defonce counter (atom 0))
11+
(def observing-mapper (map (fn [e]
12+
(swap! counter inc)
13+
e)))
14+
15+
(def in-ch (a/chan (a/dropping-buffer 32) observing-mapper))
16+
17+
(defonce enabled? (atom false))
18+
(defonce quit? (atom false))
19+
20+
(defonce generator-loop
21+
(go-loop [stream (data-gen/get-albums-xs)]
22+
#_("Introduce an appropriate delay")
23+
(if-not @quit?
24+
(do
25+
(if @enabled?
26+
(a/>! in-ch #_(FIXME stream) :dummy))
27+
(recur #_(FIXME stream) :dummy)))))
28+
29+
(defn enable-stream! []
30+
(reset! enabled? true))
31+
(defn disable-stream! []
32+
(reset! enabled? false))
33+
;; Outline:2 ends here

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /