Fork me on GitHub
#lein-figwheel
<
2016-07-17
>
andrewboltachev13:07:43

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

bhauman15:07:39

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

bhauman15:07:35

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

bhauman15:07:24

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

bhauman15:07:45

the function is very reloadable

bhauman15:07:56

and then defonce the go-loop itself

andrewboltachev15:07:51

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

bhauman15:07:09

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

bhauman15:07:56

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

andrewboltachev15:07:58

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

bhauman15:07:08

🙂

andrewboltachev15:07:58

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?

bhauman15:07:49

@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 ...

bhauman15:07:13

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

bhauman15:07:57

I would personally almost always use react...

bhauman15:07:15

but there is a learning curve

andrewboltachev15:07:15

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

bhauman15:07:58

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