Fork me on GitHub

@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.


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?


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


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


ah, right, yeah, okay that makes sense


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


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


how can i round numbers in clojurescript ?


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

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


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


@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


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


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


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


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


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.


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