Fork me on GitHub
#clojurescript
<
2019-04-23
>
orestis05:04:21

@lilactown last time I asked itโ€™s not really possible. Unless you manage to cleanly separate all the namespaces that require spec so that they are outside the main dependency graph. Which is hard in practice.

idiomancy14:04:46

does anyone have any tips for dealing with timeout exceptions when working with core.async and external api calls? The timeouts basically crash the channels which eventually leads to an OOM death. The problem is that the timeouts only seem to occur in the prod environment and I'm having trouble figuring out which calls are timing out :/ Is there like a pattern for stabilizing the number of allowed concurrent promises, and for handling timeouts in promises?

idiomancy14:04:12

(I'm just making the promises put their results onto channels)

mccraigmccraig14:04:33

@idiomancy turn the timeouts into values, put them on the result channel and process them

idiomancy14:04:36

ah, right, yeah, okay that makes sense

souenzzo14:04:34

TIP: Tools to explore bundle like this: https://www.npmjs.com/package/source-map-explorer also works in cljs using :source-map true to generate source maps then npx source-map-explorer main.js main.js.map

idiomancy14:04:45

if that does what it promises well, thats a game changer

abdullahibra15:04:16

how can i round numbers in clojurescript ?

souenzzo15:04:47

Checkout see also There is some fns in clojure.core, like (int 3.2) => 3

Roman Liutikov15:04:31

or even (Math/round n), for cross-platform code

๐Ÿ‘ 4
abdullahibra15:04:31

great, thanks guys

Mario C.16:04:56

How would I call $(document).foundation() within my CLJS code? I tried doing (.-foundation js/document) but that didn't seem to work.

Roman Liutikov16:04:35

(.foundation (js/$ js/document))

๐Ÿ‘ 4
Roman Liutikov16:04:51

.- is for prop access

Jimmy Miller16:04:05

But you are also missing the call to jquery.

๐Ÿ‘ 4
Mario C.16:04:38

Worked like a charm, thanks!

Mario C.16:04:35

I am running into issues and I dont know how to work around them. I have a div that uses css/JS from Foundation. They say to add <script>$(document).foundation()</script> at the bottom of your html file, after including Jquery and Foundation. After doing so the div is not behaving as expected. But if I go into the console and manually run $(document).foundation() then the div works as expected. I thought maybe if I add that Jquery call in my ComponentDidMount function then it would work but that was not the case. Any idea on what I can do to get the JS properly working?

Mario C.16:04:23

Do I have to add Foundation into my cljs build?

Roman Liutikov16:04:08

one thing could be that jQuery requires a method to be called with a proper context

Mario C.16:04:21

@roman01la What do you mean by this?

Roman Liutikov16:04:27

ignore this, I thought compiler would emit code that calls a method without proper this, but itโ€™s ok

Mario C.18:04:11

The workaround I did was (js/setTimeout #(.foundation (js/$ js/document)) 1000). This got it working. Did this call in a IDidMount

thheller18:04:13

@mario.cordova.862 that looks very brittle. are you maybe loading the foundation stuff in the wrong order? ie. after the CLJS code?

Mario C.18:04:30

@thheller I dont like the solution either but I couldn't figure it out. I believe I am loading in the correct order. Its before the CLJS code

thheller18:04:35

do you load it async? <script async...> or <script defer ...>?

Mario C.18:04:10

It doesn't look like I specify either way

Mario C.18:04:25

just <script src=""...>

Mario C.18:04:57

It seems though I need to load the script after the CLJS code since thats what it looks like I am doing with the setTimeout

thheller18:04:24

do you load all the scripts in the <body>?

thheller18:04:22

oh .. I missed that you are using this with react

thheller18:04:59

ok then the issue is probably that react will add an element to the page after foundation scanned the DOM for elements it should attach to

thheller18:04:37

foundation and the react model don't really fit together

Mario C.18:04:52

I believe so but even adding the 'reflow' to the foundation() call doesn't do anything.

Jimmy Miller19:04:42

Any time you are doing dom manipulation via libraries like jquery and using react you are going to have a lot of complications. I'd really recommend against doing that by either finding a library that has wrapped up the foundation functionality you want to make it react compatible, or by choosing a more react friendly library.

Mario C.20:04:28

Yea I decided to ditch the workaround and just implement the css, which I should have done from the start oh well lol