Fork me on GitHub
#cljsrn
<
2016-02-18
>
adamfrey00:02:10

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

seantempesta22:02:42

@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

seantempesta22:02:59

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.

adamfrey22:02:29

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

adamfrey22:02:31

actually my brainstorm idea wouldn’t work, nvm.

adamfrey22:02:07

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

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

adamfrey22:02:12

hold on let me do a little experiment

seantempesta22:02:30

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?

adamfrey22:02:52

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

adamfrey22:02:40

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.

seantempesta22:02:17

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.