Hello! Is there a good resource for getting started with re-frame? Have gone through the understanding re-frame
course in <http://purely-functional.tv|purely-functional.tv>
and I think I do grasp the general concepts already, but it still seems like a leap to start using it. Should I just try and figure it out along the way? 😮
The main re-frame documentation and examples.
will try starting from there then hmmm
The re-frame documentation really helped me to understand the underlying concepts. There is a free course by Jacek Schae available here: https://www.jacekschae.com/courses/learn-re-frame-free/
For learning purposes only, I wanna try building a simple drawing app where you can draw and drag around shapes on a HTML5 canvas... Would you suggest that I keep information about very low-level and very often updating stuff like mouse coordinates, if a button is held down or not etc in the re-frame db or should I just use reagent atoms?
Use app-db
only for the things you consider to be a part of you app's state. To help you visualize it a bit - think of everything that might benefit from the undo/redo functionality, from the ability to save it and restore later, to serialize it in full for e.g. some reporting.
right. so I would store things like active shapes in the add db but mouse coordinates etc low level details in a reagent atom or something
That's what I would do.
But I remember at least one person saying that they store everything in app-db
- mouse cursor position, animation transition states, etc.
Okay, thanks for the advice. Makes more sense to me to keep very low level details outside the db
also in my experience keeping very rapidly changing values (e.g. scroll position) in the db can be a bit laggy
Is there a way to tell re-frame/reagent to redraw the canvas when the data of a subscription changes? or should I manually call render-canvas
after adding a shape or something? https://gist.github.com/Sose/a8341b8a33e32c51d8cd3f3ad194bcb7#file-drawing-cljs-L63
Assuming I understand you correctly, you can simply put @shapes
inside the :reagent-render
, just at the very start of its body.
The deref will make Reagent register this reaction and any change will trigger :component-did-update
.
Ahh, thanks again! That seems to work.