Trying to learn better state management in Reagent

I’ve been working on an implementation of Minesweeper in Reagent. Once I got a working game with all the features I wanted, I decided to add height/width controls for a variable grid size. This ended up revealing a huge performance hit on very large grids, and giving me an opportunity to learn more about Reagent’s various features for managing state. I believe the problem was simply that every square was being rerendered every time due to dereffing the same atom.

I think I came up with a solution using cursors, but I could use some feedback on whether I’m using the right approach. I feel that I might be missing some obvious things, or doing some rather silly things. I’d really appreciate it, thanks!

I have little experience with reagent, but I think you took the right approach.

However you may consider refactoring your app to use the re-frame framework, in particular using subscriptions instead of cursors:

(doc re-frame.core/subscribe)

Given a query, returns a Reagent reaction which, over
time, reactively delivers a stream of values. So in FRP-ish terms,
it returns a Signal […]

From the link you provided:

Reactions are like cursors called with a function.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.