how to do live reload in browser using CIDER+Ring+Jetty?

how to do live reload in browser using CIDER+Ring+Jetty?

I have a question, but I have no idea if what I'm asking for is even possible.

In the ClojureScript world, there is fighweel that allows you to immediately see changes in the browser.

I'm busy with a server-side project (using Emacs+CIDER nREPL+ring+jetty), so no figwheel and I would like to achieve the following:

when I change an html-generating function, and use C-x C-e in Emacs to apply the changes, the CIDER repl knows about the update, but the browser doesn't know about it yet. I have to manually refresh every time.

Is there a hack or hook or something that, when CIDER knows a function has changed, the browser gets an update (possible using some automatically injected javascript?) – I did use wrap-reload, but it seems that doesn't do what I expected..


Submitted February 23, 2018 at 08:42PM by kvtb
via reddit

Re-frame subscription question

Re-frame subscription question

What's the best way to write a re-frame subscription equivalent to this:

(let [a @(subscribe [::foo input-value]) b @(subscribe [::bar a])] (f a b)) 

The issue is that the ::bar subscription depends on the result of the ::foo subscription. In my actual use case, the first subscription tells me which event I'm currently looking at and the second subscription gets more info about that event. Worse, the second subscription is hitting my server, so I can't even sidestep the issue by using the entire app-db as my input signal.

My first thought was this:

(reg-sub ::my-sub (fn [[_ input-value]] (let [a-sub (subscribe [::foo input-value])] [a-sub (subscribe [::bar @a-sub])])) (fn [[a b]] (f a b))) 

Unfortunately, the signal function is only ever applied once, so the ::bar sub doesn't update when the ::foo sub changes.

Instead, I'm currently using this:

(reg-sub ::my-sub (fn [[_ input-value]] (subscribe ::foo input-value)) (fn [a] (let [b (subscribe [::bar a])] (f a b)))) 

This works fine, but I feel like I'm not really getting much value out of the input-signals function. Also, the body of my subscription is no longer pure and so it is somewhat awkward to test. Finally, the ::bar subscription can't easily depend on input-value, which can be somewhat annoying as well.

Submitted February 21, 2018 at 10:07AM by retief1
via reddit