Fork me on GitHub
#clojurescript
<
2020-05-24
>
rafalw03:05:49

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?

jaide04:05:29

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.

mikethompson04:05:57

Coeffects can't be async

mikethompson04:05:28

@rafal.wysocki HTTP requests are effects.

mikethompson04:05:09

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.

mikethompson04:05:35

So the necessary HTTP requests are computed by the event handler, and returned as data. The effects handlers will then action those effects.

mikethompson04:05:23

The event handler may also compute that a spinner appears

mikethompson04:05:15

Sometime later, those two HTTP responses will come back. And that will be via two other events.

mikethompson04:05:31

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.

mikethompson04:05:24

Note: there's a #re-frame channel

victorb12:05:52

anyone know of any tools that finds code duplications in clojurescript codebases? Did some search around but haven't found any

jjttjj12:05:42

what's the best way to "disable-console-print!"

thheller12:05:57

(set-print-fn! (fn [x]))

👍 4
jjttjj13:05:03

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

jjttjj13:05:19

It appears to be a closure "namespace"

thheller13:05:02

(:require [goog.fs.blob :as blob]) (blob/whatever ...)

jjttjj13:05:04

I keep getting

The required namespace "goog.fs.blob" is not available, it was required by "myns.cljs".

jjttjj14:05:54

Should have checked the commit date for that, thanks again!

thheller14:05:05

[goog.fs :as fs] (fs/getBlob ...) should work

Andreas S.14:05:36

Hi everyone I wanted to try this: https://clojurescript.org/guides/quick-start , but I do have windows and java 11

Andreas S.14:05:46

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

Andreas S.14:05:36

Is this a known issue? do I have to use java 8 on windows? is there no way to use java 11?

thheller14:05:15

@andreas.scheinert this has nothing to do with your java version. did you check what the error message is telling you?

Eliraz15:05:33

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?

lilactown16:05:18

@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

lilactown16:05:42

I don’t see any concrete benefits for using it for general state management

lilactown16:05:19

if your intent is to learn core.async, then go for it :) but you probably wouldn’t use it with an atom

dvingo16:05:22

there's some really cool core.async techniques in this classic: https://youtu.be/AhxcGGeh5ho?t=2485

krzyz16:05:31

@eliraz.kedmi Think of a channel as a queue you are putting between a producer and consumer to decouple them.

Andreas S.17:05:21

@thheller Hi! yes thank you. The source file was missing

Eliraz17:05:51

@lilactown Yeah well, doing that, will it mimic the concurrent mode of react?

lilactown17:05:53

No, core.async and react concurrent mode have a number of technical differences

Andreas S.17:05:44

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

Andreas S.17:05:06

I modifed my deps. edn as in the tutorial provied. as the cls file

dpsutton18:05:44

Which page?