Fork me on GitHub

For andare users, is alt! working for you? I have:

  (step-chan :attempt-commit ...) ([value] value)
  (async/timeout *stm-default-timeout*) (timeout-error-state state errors history)
  :priority true)
But I keep getting both clauses called (timeout AND vale)


I am worried I am not getting the syntax right


when you say you are getting both, does the alt! call return both? or do you just mean that both are realized?


No it returns the timeout error


but if I use <! only the call is not timing out


and I see println from step-chan so it is executed as well


Maybe the problem is not core.async but the code converting from a promise to a channel actually


@dnolen Given the compiler state, is there a way to macroexpand a cljs form from the clj side? cljs.analyzer/macroexpand-1 needs an env; is that part of the compiler state? This is related to tooling:


Hey all I am trying learn how use :npm-deps. I am trying to replicate the example using react but whenever I try to load my page with reagent using the :npm-deps react my page fails to load complaining that process isn't defined however I have explictly enabled :process-shim. Any ideas?


So upon further investigation it seems that react, more specifically emptyobject.js (which checks process), fails to load and causes react to fail to do so. Anyone else encountered this?


@xiongtx pretty sure you just need to supply an analysis environment


isn’t there a cljs.analyzer.api/macroexpand thing-y?


There’s no cljs.analzyer.api/macroexpand. There’s cljs.analyzer/macroexpand, but I’m not sure how to get the analysis environment.


Please fill out the survey if you haven’t already 🙂


So I’m struggling to figure out how to do a server-based (node) CIDER session with ClojureScript. I’m basically looking to evaluate s-exps within my editor and get results back. It seems though that most REPL solutions for CLJS are via figwheel?


The node story is quite poor to be frank, I am using lumo for that but no cider, I am using inf-clojure


Ah. Thanks.


I’ve been using lumo (however I don’t have it hooked into cider). I think there’s some work with getting it hooked using inf-clojure


Does anyone know why the following test will fail to apply the redef?

(deftest download-file-fail-throws-error
  (async done
    (with-redefs [project.s3/download-file #(js/Promise. #(%2 "error")
                  project.util/delete-file-sync identity]
      (-> (upload-pdf)
          (.catch (fn [error]
                    (is (= error "error"))


in js, async tests conflict with with-redefs


Gotcha, is there any workaround?

joelsanchez17:02:15're pretty much f*cked but there are hacks that work in some cases, like that macro that used set!...


Thanks for the link! I’ll check it out 🙂


actually, the last link is the one with the set! macro 😂


Haha, that could be a short term solution!


I see that it’s resolved as not a bug. Do you happen to know why that was?


I remember something like "intented behavior" from someone important 🙂


the best thing to do is replace code that needs with-redefs with code that doesn’t need with-redefs because the thing you would redefine is a first class argument to the function (this applies even when with-redefs doesn’t break, on cljs or clj)


yeah, @dnolen says it's not a bug


Ahhh, that makes sense. So it encourages better structure


an optional argument or something that uses partial to construct the function used in actual code are options to keep that function elegant to use, but providing something as an arg instead of redefining globally avoids a lot of pain


oh, and a third way to make it easier to use is to pass in an implementation map (this combines nicely with libs like stuartsierra/component that provide you a map of implementations of things that rely on initialized state)


of course the other option is to rethink the test to avoid asynchrony, for example you could move the code that does the server request out of the "upload-pdf" fn, and simply ensure it executes the other fn with proper args


that’s true as well - in general isolating channel usage and talking to outside entities are both big wins when making something you can test and reason about


Thanks you all! Will rethink some of the testing


I have a multi module clojurescript project


Local checkout and refreshing the project doesn’t work


I mean when I modify the project, another project which imports the jar, doens’t see the changes right away


@rnagpal maybe try #leiningen ?


I’ve been puzzling over a clojurescript-specific problem something for over a day now: I have an upload function called upload-async that uses cljs-http to upload a file to a server. I would like to limit its concurrency, to, say, 4 uploads at once. This seems super simple, but I cannot wrap my head around it to save my life. I’m even thinking about using an atom, a watcher, and a queue to solve this problem but I can’t help but think there must be something simple to accomplish this. Any thoughts?


have a function that produces a go-block that reads a shared request channel to get a URI, then uses cljs-http to upload, then loops - call it 4 times


(that’s one way to do it at least - not smart for larger concurrency, but 4 parallel uploads seems reasonable that way)


oh wait - it’s not that simple - it needs to park on the chan cljs-http returns, then loop


@noisesmith that’s pretty close to where i’m going: a concurrency atom + queue. the function checks concurrency and dump the uri into the queue if concurrency is too high, then basically the first 4 calls to the function will drain the queue by parking on the cljs-http channel then checking the queue


if you take input from a channel you get the queue management for free


I might think differently if you aren’t already bought into core.async, but cljs-http makes that decision for you


i’m probably being dense here, but how does that work? right now i just do a (upload-file js-file-object). Are you suggesting that I change that to (put! global-upload-channel js-file-object)?


right, or you can define a function that does the put! if you want to leave the API unaltered for consumers


that makes sense. thanks!


So upon further investigation it seems that react, more specifically emptyobject.js (which checks process), fails to load and causes react to fail to do so. Anyone else encountered this?