Fork me on GitHub
Kovas Palunas21:10:21

Hey all! I'm working on my first app in reagent and think my understanding of async logic is a bit flawed. I'm calling a graphing function at that should display svg in my app. However, my reddit-comment-graph atom is not being updated before this call occurs, so no graph is displayed. To my surprise, the atom IS updated in, just one line above, and the data is properly being printed as HTML. Any ideas why this is happening and how I can get my graphing function to be called after my atom is updated just like the raw HTML?


Can you try changing from

(rt-g/viz reddit-comment-graph)
[rt-g/viz reddit-comment-graph]


My theory is that because it’s a function and not a component, it doesn’t listen for state changes on reddit-comment-graph


Changing it to a component instead should cause viz to handle watching for state changes itself

Kovas Palunas06:10:43

thanks for the idea! that doesn't seem to help unfortunately : (. i get the same result with ( and [.

Kovas Palunas06:10:27

fwiw, in the end my graphing function returns a rid3/viz component

Kovas Palunas06:10:41

i wonder if maybe the way it's set up hardcodes everything on the first call and doesn't update properly?

Kovas Palunas06:10:13

actually, my code was throwing an error earlier that made it so the update never happened

Kovas Palunas06:10:23

this issue as i described it is resolved!

🎉 1
Kovas Palunas06:10:13

(i was initializing my reddit-comment-graph atom without the fields that rt-g/viz expected, leading to a crash on the first call before the atom was populated with real data)

Kovas Palunas06:10:36

now my graph isn't showing up, but the data is flowing through the function properly at least. progress!

👍 1