fix #1216: fix core.async alts example with polyfill

This commit is contained in:
Michiel Borkent 2022-03-23 23:48:09 +01:00
parent c3cae22541
commit 1ad93077c1
3 changed files with 14 additions and 1 deletions

View file

@ -12,6 +12,10 @@ A preview of the next release can be installed from
- [#863](https://github.com/babashka/babashka/issues/863): allow pods to be declared in `bb.edn` and load them when required - [#863](https://github.com/babashka/babashka/issues/863): allow pods to be declared in `bb.edn` and load them when required
- See [updated pod library docs for details](TODO: link) - See [updated pod library docs for details](TODO: link)
### Enhanced
- [#1216](https://github.com/babashka/babashka/issues/1216): support `core.async/alts!` using polyfill
## 0.7.8 (2022-03-13) ## 0.7.8 (2022-03-13)
This release improves compatibility with several libraries: [loom](https://github.com/aysylu/loom), [hugsql.core](https://www.hugsql.org) and [specter](https://github.com/redplanetlabs/specter)! This release improves compatibility with several libraries: [loom](https://github.com/aysylu/loom), [hugsql.core](https://www.hugsql.org) and [specter](https://github.com/redplanetlabs/specter)!

View file

@ -46,7 +46,6 @@
'<!! (copy-var async/<!! core-async-namespace) '<!! (copy-var async/<!! core-async-namespace)
'>!! (copy-var async/>!! core-async-namespace) '>!! (copy-var async/>!! core-async-namespace)
'admix (copy-var async/admix core-async-namespace) 'admix (copy-var async/admix core-async-namespace)
'alts! (copy-var async/alts! core-async-namespace)
'alts!! (copy-var async/alts!! core-async-namespace) 'alts!! (copy-var async/alts!! core-async-namespace)
'alt!! (macrofy 'alt!! alt!! core-async-namespace) 'alt!! (macrofy 'alt!! alt!! core-async-namespace)
'buffer (copy-var async/buffer core-async-namespace) 'buffer (copy-var async/buffer core-async-namespace)
@ -107,6 +106,7 @@
'<! (copy-var async/<!! core-async-namespace) '<! (copy-var async/<!! core-async-namespace)
'>! (copy-var async/>!! core-async-namespace) '>! (copy-var async/>!! core-async-namespace)
'alt! (macrofy 'alt! alt!! core-async-namespace) 'alt! (macrofy 'alt! alt!! core-async-namespace)
'alts! (copy-var async/alts!! core-async-namespace)
'go-loop (macrofy 'go-loop go-loop core-async-namespace)}) 'go-loop (macrofy 'go-loop go-loop core-async-namespace)})
(def async-protocols-ns (vars/->SciNamespace 'clojure.core.async.impl.protocols nil)) (def async-protocols-ns (vars/->SciNamespace 'clojure.core.async.impl.protocols nil))

View file

@ -33,3 +33,12 @@
(is (number? (edn/read-string (test-utils/bb nil " (is (number? (edn/read-string (test-utils/bb nil "
(def ^:dynamic x 0) (def ^:dynamic x 0)
(binding [x 10] (async/<!! (async/thread x)))"))))) (binding [x 10] (async/<!! (async/thread x)))")))))
(deftest alts-test
(is (true? (edn/read-string (test-utils/bb nil "
(= 10 (first (async/<!!
(async/go
(async/alts!
[(async/go
(async/<! (async/timeout 100))
10)])))))")))))