@ps try doing this instead
(require '[re-frame.core :as rf])
(rf/reg-fx
::get-from-async-storage
(fn [{:keys [key when-retrieved]}]
(-> (. AsyncStorage getItem key)
(.then
(fn [value]
(rf/dispatch (when-retrieved value)))))))
Make an FX handler - this is the low level construct for defining how a side effect is performed
and give it a function to call when it is done that will return an event to dispatch with the new value
so then in your event handler
(rf/reg-event-fx
:register-db
(fn [db _]
{:db db
:fx [[::get-from-async-storage {:key "_id"
:when-retrieved #(vector :got-value %)}]]}))
(rf/reg-event-db
:got-value
(fn [db [_ value]]
(assoc db :value value)))
so you need two events
but there are (at least) two things happening that are not part of the model
try to have your fx handlers be few in number
and just write helpers on top of them
thanks
(this is what the sample i gave below does, more or less)