Fork me on GitHub
#reagent
<
2019-07-20
>
Ramzi07:07:36

how do i call core.clj functions from core.cljs? do i have to use ajax, or is there another way?

pwojnowski09:07:46

If your cljs app runs inside the browser and your ring server runs on the server side, then you will need to use some client-server approach. So, ajax would work.

Ramzi11:07:24

i tried following an article to set up a ring server, with no luck

chepprey20:07:01

I have a small Reagent app. I'm reading data off of a websocket, and I append new data to a vector in my single ratom appstate. I also eject old data, so basically imagine a table with 100 rows, with new data always added to the bottom, old data ejected from the top.

chepprey20:07:49

Then I'm generating html(hiccup) from the state, where it generates the html table (among other stuff).

chepprey20:07:58

I have this table in a scrolling window in the middle of my UI (this will be for small screens, so, you can only see 15-20 rows of data). What I would like is to always have my table automatically scrolled to the bottom every time the data is updated.

chepprey20:07:46

My problem is that I appear to have some sort of race condition. It appears that the scroll-to-bottom logic runs before the updated html is generated & rendered to the DOM.

romain20:07:25

I have a reagent atom in a separated file. In my view file I have a table in a component and an input+button in another. When I type something in and fire the button it send a POST request and then a GET to fetch new data and update (with swap!) the atom. But the table is not correctly refreshed, after the list is truncated and pressing again the button will correctly display the values. If I manually swap in repl it works well. I don't have the code at home but you may help me :)

chepprey20:07:25

Because many times (not always, but most commonly) the list is only scrolled to the next-to-last item in the table, rather than the bottom.

chepprey20:07:30

My current approach is to simply run the scroll-to-bottom code after doing swap! on my ratom. I'm wondering if there's not some other approach? Like, is there some kind of way to register "rendering postactions" in reagent?