Fork me on GitHub
#clojurescript
<
2018-12-02
>
caleb.macdonaldblack06:12:30

Using core.async, would it be better to return a channel from a function or pass one in?

Chris08:12:06

If passed in the caller has more control, they can put transducers on the channel or close it whenever.

darwin12:12:08

return by default, optionally pass in, here is an example from a recent cognitect lib: https://youtu.be/ppDtDP0Rntw?t=1783

orestis07:12:34

Is this expected under Clojurescript?

(map int "abcde")
;; => (0 0 0 0 0)

jaihindhreddy-duplicate09:12:13

It returns the ascii-codes in clojure (97 98 99 100 101). Weird.

helios09:12:22

i thought i had seen a bug somewhere in Jira/CLJS

orestis13:12:52

Vote if you care about this 🙂

helios09:12:06

there is a patch proposed as well 🙂

souenzzo13:12:07

cljs dont have char type I have a branch with a (deftype Character [c]) but there is a lot of problems with cljs implementations (for example, cljs.pprint) that expect the return of (first string) to be a string

mfikes15:12:01

Yeah, there is likely a lot of code in the wild too. My suspicion is that this can't be done as a non-breaking change.

👍 4
ampersanda13:12:17

Excuse me, I am currently learning making PWA using reagent, but I have a trouble when checking the service worker. How do I convert (javascript) if ('serviceWorker' in navigator){} into Clojurescript? I tried using (when (in 'serviceWorker' js/navigator)) but it throws error that in is not avaiable

rutledgepaulv14:12:09

(when (contains? js/navigator "serviceWorker") ...)

ampersanda14:12:08

It works but it returns wrong value It should returns true (I tested in Chrome)

willroe14:12:35

You can do (.-serviceWorker js/navigator) - it'll be nil in browsers without that feature

jaihindhreddy-duplicate14:12:54

Is deftype portable Clojure, especially when using mutability?

mfikes15:12:54

deftype in ClojureScript works essentially like it does in Clojure. In particular ^:mutable is supported on fields.

Logan Powell14:12:26

👋 Hi everyone! Is there something I need to be aware of in terms of keeping a function alive across calls in JS land? In this example, I'm trying to cache the last value, which works when I'm in the REPL/development, but when I release compiled js (on NPM) and import it, it never hits the cache...

Logan Powell14:12:35

This is just a toy example... I have to coordinate API calls across multiple APIs in a specific order

ckiehl23:12:24

Anyone know of any open source Clojurescript + Reagent projects that make for good studying? I'm specifically trying to find a few larger(ish) projects which use core.async that I could dig into and learn from.

victorb00:12:28

not Reagent but om: Circleci's frontend: https://github.com/circleci/frontend Might make a good study for general clojurescript architecture

ckiehl00:12:18

Awesome. Looking into it now! Thanks for the tip!

victorb01:12:47

also, this search might help you to find more of them: https://github.com/topics/clojurescript?o=desc&amp;s=stars seems it's mostly libraries though, but LightTable/LightTable seems application-ish enough to qualify as well

ckiehl01:12:39

That github query was where I started the hunt before coming to bug you guys on here ^_^ It def skews a little more towards the library side of things. I've tried narrowing it down a little more with core.async + reagent keywords, but... then all the results disappeared