My solution for this was
(defn next-state [previous current]
(case previous
"in-other-app" (case current
"active" "back-from-other-app"
"inactive" "in-other-app"
"background" "in-other-app")
"back-from-other-app" current
current))
(def previous-state-atom (atom (.-currentState app-state)))
(defn add-app-state-listener [f]
(.addEventListener app-state "change"
(fn [state]
(let [current-state (next-state @previous-state-atom state)]
(f current-state)
(reset! previous-state-atom current-state)))))
Basically i keep track of what the previous state was and used that and the next state to fire a custom event (i.e. trigger a function with a string a the event)
Hope this helps somebody...
Edit:
i forgot about this:
(defn mark-open-other-app!
"!!!MUST CALL!!! before any call that results in the opening of another app
like ImagePicker/showImagePicker or c/open-link."
[]
(when (= :android (di/device))
(reset! previous-state-atom "in-other-app")))
to set the correct state when going into another app.
(defn cancel-open-other-app!
"Api's like ImagePicker/showImagePicker can be cancelled in which case this function must be called to reset the app state"
[]
(when (= :android (di/device))
(reset! previous-state-atom "active")))
and this one to setup stuff back when you cancel.