This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-05-24
Channels
- # announcements (2)
- # babashka (31)
- # beginners (608)
- # cider (60)
- # clj-kondo (22)
- # cljsrn (28)
- # clojure (14)
- # clojure-europe (5)
- # clojure-nl (3)
- # clojure-spec (1)
- # clojure-uk (19)
- # clojurescript (38)
- # conjure (20)
- # cursive (9)
- # data-science (26)
- # datascript (4)
- # datomic (19)
- # duct (4)
- # emacs (8)
- # figwheel-main (5)
- # fulcro (7)
- # helix (15)
- # leiningen (12)
- # malli (2)
- # off-topic (20)
- # overtone (3)
- # pathom (14)
- # pedestal (10)
- # re-frame (2)
- # reitit (13)
- # ring (13)
- # shadow-cljs (18)
- # spacemacs (8)
Hi, I've just read re-frame guide and I'm trying wrap my head around it. I'm not sure how to handle situation like that: I have event-handler which before executed needs to have data from 2 independent HTTP GET requests to external services. When/where those request should performed? It looks like good place to put data from them is coeffects, but can coeffects function be async? If not how to handle this case in most idiomatic way?
Coeffects function can be async and are likely the best place for it. Though there are some re-frame helpers for making actual requests that may be helpful.
Coeffects can't be async
@rafal.wysocki HTTP requests are effects.
Say, the user clicks a button to request seeing xyz panel. An event will be dispatched, when the button is pressed. The event handler (for that event) is responsible for knowing how to compute the effects of that event. The event handler turns the "user intent" into "necessary changes". And the effects are that two HTTP requests should be initiaited.
So the necessary HTTP requests are computed by the event handler, and returned as data. The effects handlers will then action those effects.
The event handler may also compute that a spinner appears
Sometime later, those two HTTP responses will come back. And that will be via two other events.
With the responses both received, the new state of the application can be computed in another event handler. It may choose to take down the event handler.
You probably want to look at https://github.com/Day8/re-frame-http-fxand perhaps https://github.com/day8/re-frame-async-flow-fx
Note: there's a #re-frame channel
@mikethompson thanks
anyone know of any tools that finds code duplications in clojurescript codebases? Did some search around but haven't found any
One more: how can I use the functions here: https://google.github.io/closure-library/api/goog.fs.blob.html ? I've tried both importing and requiring the namespace
I keep getting
The required namespace "goog.fs.blob" is not available, it was required by "myns.cljs".
@jjttjj the closure-library version CLJS currently uses is too old for that ns. https://github.com/google/closure-library/commit/9089142b0652412ad16b237f0989a5de8b7ca9aa#diff-296e6eab80d6383333274d34ee5a652c
Hi everyone I wanted to try this: https://clojurescript.org/guides/quick-start , but I do have windows and java 11
so I get this this exception: Exception in thread "main" clojure.lang.ExceptionInfo: null {:clojure.error/phase :compilation} Caused by: java.lang.IllegalArgumentException: Namespace hello-world.core does not exist. Please check that namespaces with dashes use underscores in the ClojureScript file name
Is this a known issue? do I have to use java 8 on windows? is there no way to use java 11?
@andreas.scheinert this has nothing to do with your java version. did you check what the error message is telling you?
Hey everyone, I got an idea in my mind, though I'm not sure I fully understand core.async
, I was thinking that I could use channels
as reducers to an atom
or just a map
which then could handle multiple requests to change the state more gracefully, does this make any sense?
@eliraz.kedmi I’ll answer you here: core.async is good as a tool for organizing highly concurrent systems. It’s a lot of work, though
if your intent is to learn core.async, then go for it :) but you probably wouldn’t use it with an atom
there's some really cool core.async techniques in this classic: https://youtu.be/AhxcGGeh5ho?t=2485
@eliraz.kedmi Think of a channel as a queue you are putting between a producer and consumer to decouple them.
@thheller Hi! yes thank you. The source file was missing
@lilactown Yeah well, doing that, will it mimic the concurrent mode of react?
ok, I'm trying the last step of the tutorial on the clojurescript page, the cljsjs/react-dom example but I get the following error: Caused by: clojure.lang.ExceptionInfo: No such namespace: react-dom, could not locate react_dom.cljs, react_dom.cljc, or JavaScript source providing "react-dom" (Please check that namespaces with dashes use underscores in the ClojureScript file name) in file
I modifed my deps. edn as in the tutorial provied. as the cls file