re-frame

https://github.com/Day8/re-frame/blob/master/docs/README.md https://github.com/Day8/re-frame/blob/master/docs/External-Resources.md
zackteo 2021-05-24T08:14:21.025200Z

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? 😮

p-himik 2021-05-24T08:22:25.025300Z

The main re-frame documentation and examples.

👍 1
zackteo 2021-05-24T08:26:19.025500Z

will try starting from there then hmmm

Oliver 2021-05-24T08:54:39.025700Z

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/

🙏 2
Joni Hiltunen 2021-05-24T16:42:27.028500Z

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?

p-himik 2021-05-24T16:46:10.028600Z

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.

Joni Hiltunen 2021-05-24T16:46:58.028800Z

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

p-himik 2021-05-24T16:48:18.029Z

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.

Joni Hiltunen 2021-05-24T16:50:15.029200Z

Okay, thanks for the advice. Makes more sense to me to keep very low level details outside the db

👍 1
afleck 2021-05-24T17:32:47.029500Z

also in my experience keeping very rapidly changing values (e.g. scroll position) in the db can be a bit laggy

Joni Hiltunen 2021-05-24T17:51:50.030600Z

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-canvasafter adding a shape or something? https://gist.github.com/Sose/a8341b8a33e32c51d8cd3f3ad194bcb7#file-drawing-cljs-L63

p-himik 2021-05-24T17:53:42.031100Z

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 .

Joni Hiltunen 2021-05-24T17:54:58.031300Z

Ahh, thanks again! That seems to work.