Fork me on GitHub
#reagent
<
2021-12-31
>
Richie04:12:26

Hey! What's the difference between reagent.ratom/run! and reagent.core/track!? I want to save my app-db r/atom to localStorage whenever my app-db changes. I saw https://github.com/reagent-project/reagent/blob/master/doc/ManagingState.md#the-track-function-1 for track! that sound like what I want but I don't like that I have to define two things (seems cumbersome) and it didn't seem to work reliably (that may be because I was trying it with an anonymous function). Then I https://www.mail-archive.com/[email protected]/msg00087.html run! and that seems nice and easy. It seems to work now. Will it continue to do what I want? What's the difference? They both make a reaction with auto-run set to true. That's as much as I can understand from looking at the source. Thanks!

juhoteperi07:12:18

track! identity keeps the reaction same if used inside a Reactive context, like component render fn body. If you had run! in render fn, it would start new one each render.

Richie13:12:42

Ok, thank you! I think I understand. It sounds like run! will work perfectly for how I'm using it.