Fork me on GitHub

@seantempesta @adamfrey : I’m starting out a new RN project and trying to decide whether to use re-frame or om-next. My initial impression is that re-frame is cleaner and more minimalistic, I like how reagent components are just data. The relay/graph-ql part of om-next is obviously quite intelligent, I’m unsure if it’ll be needed for my app though. Every user will only work with its own data and hence not as much sync with the cloud is needed and at the moment we do not have any plans on a web ui so the api endpoints will be tailored for mobile. The property based testing part should be portable to re-frame since it also has a single source of truth and serializable events. These are my initial thoughts, why did you guys choose om-next? If anyone else has experience with either I’d be grateful for your experiences.


I’m using mostly because I want to really learn the query and remote fetch/mutation properties and see if they are a huge improvement in writing UIs. Frankly I’m tired of writing repetitive and inflexible backends.


@vikeri: Yeah, I wanted to learn something new. At this point I’m thinking of switching to reagent (maybe Posh) and letting bake a little longer.


Not being able to have react components as intermediaries (ex. react-navtive-router*) is kind of rough.


Ok thanks! Yeah I really liked how effortless it was to include a react lib in reagent...


I’ve put some decent hours into re-frame and I think it’s a solid architecture.


Ok good to hear! I spent a year with om (old) and re-frame seems to address the majority of the pain points we encountered in that project.


What are your preference on boot vs leiningen btw?


I haven’t really explored boot. People I respect in the community seem to think it’s great.


inhortte: It's js/fetch. You can use cljs-ajax for a more easy interface.


@jellea: Not sure what you were referencing, but for what it’s worth I wrote some helper functions to use js/fetch that can be used to request json and process it.

(defn process-status
  "Checks the server reponse for a 200 or 0 and resolves/rejects the promise"
  (if-let [status (.-status response)]
    (if (or (= status 200) (= status 0))
      (.resolve js/Promise response)
      (.reject js/Promise (js/Error. (.-statusText response))))))

(defn process-json
  "Calls .json on the response and resolves the promise"
  (let [json-promise (.json response)]
    (.then json-promise #(.resolve js/Promise %))))

(defn json
  "Simplifies fetch to either succeed and parse the json or fail.
  You can specify a timeout too!"
  [url success fail max-wait]
  (let [failed? (atom false)
        fail-fn #(if (not @failed?) (do (reset! failed? true) (fail %)))
        timer (js/setTimeout #(fail-fn :timeout) max-wait)]
    (-> (js/fetch url)
        (.then process-status)
        (.then process-json)
        (.then #(when-not @failed?
                 (do (js/clearTimeout timer)
                     (success (js->clj %)))))
        (.catch #(fail-fn %)))))


seantempesta: inhortte asked a question about it yesterday. But thanks, using transit myself though and cljs-ajax comes with support out of the box


ah, gotcha. I didn’t realize it worked in react-native. Good to know.


@jellea Thanks. I'll have to pull the project I was playing with during the weekend up again and try cljs-ajax. I've used it before, so it makes sense.


@seantempesta: I tried something like your (-> (js/fetch url) (.then ...)) construct on my android emulator and it failed. I don't have the precise error in front of me at the moment, however.


Hmm, I dunno. I didn’t test it on Android, but I believe the js/fetch api should also exist on Android.


@seantempesta: I'll try it again tomorrow and post results here. It may just be my configuration of the AVD, as I am a bit of a newbie in this arena.