Fork me on GitHub
#clojurescript
<
2022-03-12
>
Cora (she/her)00:03:19

or (into [a] b) then conj c onto the end

Cora (she/her)00:03:53

for simple collections concat is fine, though

Stuart14:03:51

I'm playing around trying to learn a js package called cytoscape.js. I'd like to eventually use it as part of a bigger re-frame app to do some UI drawing. So I've setup a re-frame project and I have a button to render the graph from my app-db. However, whenever it hot reloads the code the graph disappears. I have a gist here. https://gist.github.com/stuartstein777/ce6f6162eff3b4cd23cbb8c63ca42e24 I thought of defonce but I'm not that sure helps me here, or if it does I'm not understanding it. I'm using reagent and shadow-cljs too, is their a way to mark not to hot reload a certain element ? I tried just having a call at the bottom of my file to the render graph method, but the graph has draggable elements and calling this on the hot-reloading undoes all the dragging. and just resets the graph to its initial position.

p-himik15:03:53

That would be more appropriate for #reagent > I'm using reagent and shadow-cljs too, is their a way to mark not to hot reload a certain element ? I don't think so. In general, data should drive the views. As soon as you fail to abide by that maxim, hot reloading will fail as all internal state of the views will be erased, replaced by what came with hot reloading. In your particular case, you're rendering something in an effect. Do not do that - instead, do all rendering in a view function. Whenever the input data changes, update the component. If you don't want to re-render the whole component but just a part of it, then use a form-3 component with a custom :component-did-update.

👍 1
Stuart15:03:54

Thanks, that's very helpful

👍 1