When I use def to save an atom, it works as expected. But when I use defonce, I have to deref twice: @@my-state. I want to use defonce because I want state preserved during reloads.
This works as expected
(def my-state (reagent/atom (re-frame/subscribe [::subs/photos])))
This requires two derefs to access the values
(defonce my-state (reagent/atom (re-frame/subscribe [::subs/photos])))
Subscription code
(re-frame/reg-sub
::photos
(fn [db [_]]
(:photos db)))
Then just don't use Reagent's atoms, use re-frame's subscriptions instead. They derive their values from re-frame's
app-dbwhich is itself defined withdefonce.