oakes / full-stack-clj-example

A sample Clojure CLI project containing Clojure and ClojureScript
115 stars 8 forks source link

NOOB question - getting data from server to allow cljs to manipulate it #1

Open mmeroberts opened 4 years ago

mmeroberts commented 4 years ago

Hi Zach, thanks for this simple starting point. I am afraid that I am missing one element. I want to read some data files into my application at the start - I presume that I will use clj for this. However, I then want the data in those files to drive how the pages look. How do I get that data from the clj side of the app to the cljs side of the app. I suspect this is straight forward but I am simply missing that part.

Would I be wrong in thinking that the util.cljc might have some solution for this?

Thanks

Martin

oakes commented 4 years ago

This response is waaaay late because github never notified me, sorry about that. There are many ways to send data to the cljs side. For example, in dynadoc i needed to send a map of data to the client side, so i actually embedded it into the html server-side and then the client (CLJS) side reads it out of a div and merges it into the local state. Swapping the local state triggers the UI to update automatically.