lein-figwheel

andrewboltachev 2016-07-17T13:37:43.000009Z

Hi. What's the best way to "hot-reload" go blocks in Figwheel?

bhauman 2016-07-17T15:06:39.000010Z

@andrewboltachev: go blocks themselves are no problem, its normally go loops that are a problem

andrewboltachev 2016-07-17T15:22:59.000011Z

@bhauman: yes

bhauman 2016-07-17T15:23:35.000012Z

so there is a simple trick to making go-loops reloadable

andrewboltachev 2016-07-17T15:23:44.000013Z

a kill channel?

bhauman 2016-07-17T15:24:24.000014Z

farm out the body of the go loop to a simple function that returns a go block

bhauman 2016-07-17T15:24:45.000015Z

the function is very reloadable

bhauman 2016-07-17T15:24:56.000016Z

and then defonce the go-loop itself

andrewboltachev 2016-07-17T15:25:51.000017Z

aha, it's like (defonce _ (do ...this would be executed only once...))

bhauman 2016-07-17T15:27:09.000019Z

the loop is stateful and will pickup the new body def the next time around

bhauman 2016-07-17T15:27:56.000020Z

you could also dispatch different parts of the loop to different funs, etc..

andrewboltachev 2016-07-17T15:28:58.000021Z

aha, thanks, seems that I understood 🙂 I'll try that

bhauman 2016-07-17T15:29:08.000022Z

🙂

andrewboltachev 2016-07-17T15:31:58.000023Z

btw. I have to say: the reason I'm having problems like that I that I moved away from React stuff. And now wanna to make use of all that js/document.createElement etc. But you @bhauman are advocating it. My arguments now are that React makes impossible all that "install-and-go" things like jQuery UI, WYSIWYG editros, other components, and I'm not sure but guess so also canvas libraries like sigma.js. Do you think it's a good arguments to move away from React in that case?

bhauman 2016-07-17T15:33:49.000025Z

@andrewboltachev: it depends on what you are doing ... there are trade offs. But if you are going to do any sizable client side project I would use React for sure ...

bhauman 2016-07-17T15:34:13.000026Z

if you are just adding some simple functionality to some brochureware website

bhauman 2016-07-17T15:34:16.000027Z

no need

bhauman 2016-07-17T15:34:57.000030Z

I would personally almost always use react...

bhauman 2016-07-17T15:35:15.000031Z

but there is a learning curve

andrewboltachev 2016-07-17T15:35:15.000032Z

I'm rather for a complex webapp/visual editor (and even more)

bhauman 2016-07-17T15:36:58.000033Z

imperative programming always feels like you are getting more done, but you pay for that later on when its impossible to reason about your site

1👍