Skip to content

Commit b532bca

Browse files
committed
Set version to 2021.06.03-0.
1 parent 68520ca commit b532bca

File tree

6 files changed

+42
-12
lines changed

6 files changed

+42
-12
lines changed

CHANGES.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog #
22

3+
## Version 2021.06-03-0 ##
4+
5+
- Add `merge-scan` operator.
6+
- Minor improvements on `concat` and `zip` constructors.
7+
8+
39
## Version 2021.06.02-0 ##
410

511
- Update bundled rxjs to 7.1.0

assets/rxjs/externs.js

+1
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ rxjsOperators.concatAll = function() {};
166166
rxjsOperators.concatMap = function() {};
167167
rxjsOperators.concatMapTo = function() {};
168168
rxjsOperators.scan = function() {};
169+
rxjsOperators.mergeScan = function() {};
169170
rxjsOperators.merge = function() {};
170171
rxjsOperators.mergeAll = function() {};
171172
rxjsOperators.mergeMap = function() {};

deps.edn

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
:aliases
33
{:dev
44
{:extra-deps
5-
{org.clojure/clojurescript {:mvn/version "1.10.866"}
5+
{org.clojure/clojurescript {:mvn/version "1.10.844"}
66
org.clojure/clojure {:mvn/version "1.10.3"}
77
com.bhauman/rebel-readline-cljs {:mvn/version "RELEASE"}
88
com.bhauman/rebel-readline {:mvn/version "RELEASE"}

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<groupId>funcool</groupId>
55
<artifactId>beicon</artifactId>
66
<packaging>jar</packaging>
7-
<version>2021.06.02-0</version>
7+
<version>2021.06.03-0</version>
88
<name>beicon</name>
99
<description>Reactive Streams for Clojure(Script)</description>
1010
<url>https://github.com/funcool/beicon</url>

src/beicon/core.cljs

+15-9
Original file line numberDiff line numberDiff line change
@@ -323,26 +323,23 @@
323323
"Merges the specified observable sequences or Promises (cljs) into one
324324
observable sequence."
325325
[& items]
326-
(let [[selector items] (if (ifn? (c/first items))
327-
[(c/first items) (rest items)]
328-
[vector items])
329-
items (if (vector? items) items (vec items))]
330-
(apply (.-zip rx) (conj items selector))))
326+
(let [zip-fn (unchecked-get rx "zip")]
327+
(apply zip-fn items)))
331328

332329
(defn concat
333330
"Concatenates all of the specified observable
334331
sequences, as long as the previous observable
335332
sequence terminated successfully."
336333
[& more]
337-
(let [more (cljs.core/filter identity more)]
338-
(apply (.-concat rx) more)))
334+
(let [concat-fn (unchecked-get rx "concat")]
335+
(apply concat-fn (c/filter some? more))))
339336

340337
(defn merge
341338
"Merges all the observable sequences and Promises
342339
into a single observable sequence."
343340
[& more]
344-
(let [more (cljs.core/filter identity more)]
345-
(apply (.-merge rx) more)))
341+
(let [merge-fn (unchecked-get rx "merge")]
342+
(apply merge-fn (c/filter some? more))))
346343

347344
(defn merge-all
348345
"Merges an observable sequence of observable sequences into an
@@ -465,6 +462,15 @@
465462
([f ob] (pipe ob (.scan ^js rxop #(f %1 %2))))
466463
([f seed ob] (pipe ob (.scan ^js rxop #(f %1 %2) seed))))
467464

465+
(defn merge-scan
466+
"Applies an accumulator function over the source Observable where
467+
the accumulator function itself returns an Observable, then each
468+
intermediate Observable returned is merged into the output
469+
Observable."
470+
[f seed ob]
471+
(let [merge-scan-fn (unchecked-get rxop "mergeScan")]
472+
(pipe ob (merge-scan-fn #(f %1 %2) seed))))
473+
468474
(defn with-latest
469475
"Merges the specified observable sequences into one observable
470476
sequence by using the selector function only when the source

test/beicon/tests/test_core.cljs

+18-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,8 @@
169169
(let [s1 (s/from [1 2])
170170
s2 (s/from [4 5])
171171
s3 (s/from [7 8])
172-
cs (s/zip s1 s2 s3)]
172+
cs (->> (s/zip s1 s2 s3)
173+
(s/map vec))]
173174
(drain! cs #(t/is (= % [[1 4 7] [2 5 8]])))
174175
(s/on-end cs done))))
175176

@@ -237,6 +238,22 @@
237238
(done))))))
238239

239240

241+
(t/deftest observable-scan
242+
(t/async done
243+
(let [s (->> (s/from [4 5 6])
244+
(s/scan conj [1]))]
245+
(drain! s #(do (t/is (= % [[1 4] [1 4 5] [1 4 5 6]]))
246+
(done))))))
247+
248+
249+
(t/deftest observable-merge-scan
250+
(t/async done
251+
(let [s (->> (s/from [4 5 6])
252+
(s/merge-scan (fn [acc i] (s/of (conj acc i))) [1]))]
253+
(drain! s #(do (t/is (= % [[1 4] [1 4 5] [1 4 5 6]]))
254+
(done))))))
255+
256+
240257
(t/deftest observable-filter-with-ifn
241258
(t/async done
242259
(let [s (s/from [1 2 3 4 5])

0 commit comments

Comments
 (0)