Fork me on GitHub

^thanks for that. I ran into the same problem earlier today.


@adamfrey: ha. no problem. Initially I think my questions are react native related, and then later I realize I just don’t know clojure very well. simple_smile


Okay, I think this question actually is React Native related. Is there a recommended way to do routing in a reactive way? Ideally, I’d like to have om-next’s state (or query?) determine router actions. So if you set a symbol like {:current-route :home} I could react to that change and tell the router to change to a new view. I’ve looked into react-native-router, ex-navigator, and am now playing with react-native-router-flux (for it’s claim of route dispatch from anywhere). It seems like most solutions want to declare the router as a react native component and then the navigator is passed down via props. This is not the solution I want.


I’ve also been passing down the navigator js object down through my components using om’s computed properties. Another possiblity...


actually my brainstorm idea wouldn’t work, nvm.


I’m doing the actual route change in my mutate fns:

(defmethod mutate 'video/start
  [{:keys [state]} _ {:keys [id nav]}]
   (fn []
     (swap! state assoc :video/focus [:video/by-id id])
     (.push nav #js {:id "video-screen"}))})


hold on let me do a little experiment


So if my goal is to be able to load app-state from arbitrary sources (resume from local storage) and have the route change to reflect the stored state, could I even do that with props/computed props?


the react-native navigator component has an :initialRoute option. So you could store the current route the user is in localstorage , then when they close and reopen the app, pull route out of localstorage and set it as the :initialRoute


actually you could save the whole “scene stack” in storage so that if they close the app and open it back up their route history is preserved.


Interesting. I’m going to keep searching for a purely reactive solution in hopes to help my future self for tech support. If app-state could be serialized and sent over the wire I could simply run the same version of the code and swap in their app-state and have the interface reacts to the data and resume to the same state they were in.