Fork me on GitHub
#re-frame
<
2015-09-07
>
Petrus Theron05:09:48

I would like to write re-frame components where their data requirements are defined as subscriptions that will trigger a fetch (via dispatch) if it misses the cache. Otherwise, return the cached value. In the past I have fought with parameterised subscriptions, so I'm not sure this is a good idea. Has anyone tried this, or thought about it more?

roberto14:09:29

I’ve handled that in the app state. If the app state has any data present for that specific key, then I don’t fetch any data. I do that check in the handler. This is an example, but not sure if it is exactly what you were looking for https://github.com/uris77/clj-aws/blob/master/src%2Fclj_aws%2Fui%2Fasgs%2Fhandlers.cljs#L57

pupeno20:09:30

Wouldn’t it be great to have reagent/reframe implemented in cljx so we can easily and performantly run it server side?

pupeno23:09:16

@danielcompton: interesting. Sadly, Hiccup is vulnerable to XSS (unless you explicitly escape), so, I’d rather estay away from it. I suppose a compiler from reagent’s template to hiccup could generate code that is not open to XSS.

pupeno23:09:20

danielcompton: reagent’s is k, but hiccup is not.

danielcompton23:09:33

I’m not sure how that’s relevant to server side rendering though?

pupeno23:09:10

danielcompton: that blog post you pointed to is using hiccup on the server side, actual hiccup, not reagent’s.

danielcompton23:09:58

gotcha, been a while since I read that post

pupeno23:09:26

I actually have it working by executing JS on the server… I just don’t like the performance.