This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-03-03
Channels
- # admin-announcements (2)
- # beginners (18)
- # boot (118)
- # cider (12)
- # cljs-dev (12)
- # cljsrn (24)
- # clojure (142)
- # clojure-art (4)
- # clojure-bangladesh (3)
- # clojure-ireland (1)
- # clojure-italy (7)
- # clojure-norway (4)
- # clojure-poland (207)
- # clojure-russia (101)
- # clojurescript (108)
- # clojurewerkz (2)
- # core-async (6)
- # css (8)
- # data-science (23)
- # datomic (31)
- # devcards (2)
- # emacs (8)
- # funcool (25)
- # hoplon (34)
- # immutant (78)
- # ldnclj (7)
- # lein-figwheel (4)
- # leiningen (6)
- # luminus (35)
- # off-topic (1)
- # om (119)
- # onyx (43)
- # parinfer (29)
- # proton (11)
- # re-frame (25)
- # remote-jobs (1)
- # slack-help (1)
- # spacemacs (3)
- # yada (10)
Hello I'm trying to create a react native app with reframe and have set up a re-natal project but I'm not sure how to do navigation, can anyone linke me to some good resources?
@sllyq: Have a look at Luno example app https://github.com/alwx/luno-react-native
How can I make my GET requests work? I need to execute them async, and seems like cljs-ajax or cljs-http don't work in my case. Maybe it is because of CORPS, but I don't know how to fix it.
The most interesting thing is that calling js/Fetch works perfectly. But I don't know how to execute everything asynchronously in this case.
@alwx: Could be that those libs rely on window/document which is not available
although you can use fetch or standard XmlHTTRequest
(register-handler
:monitoring
(fn [db [_ {:keys [session]}]]
(let [req (js/fetch (str config/api-url "/monitoring?session=" session))]
(-> req
(.then (fn [response]
(.text response)))
(.then (fn [responseText]
(let [response (-> (.parse js/JSON responseText)
(js->clj)
(keywordize-keys)
:data)]
(dispatch [:get-data-success [:monitoring response]]))))
(.catch (fn [error]
(dispatch [:get-data-failure [:monitoring error]])))))
(assoc-in db [:data :loading?] true)))
so, what it the issue then?
Am, everything is async
official documentation suggests the following:
async getUsersFromApi() {
try {
let response = await fetch(' ');
let responseJson = await response.json();
return responseJson.users;
} catch(error) {
// Handle error
console.error(error);
}
}
it’s a promise which are async
Hm, I’m not following - all IO in react native is async by default, fetch uses promises under the hood in order to handle it a bit easier
>Using then and catch in synchronous code:
got it - I guess this is a mistake in documentation. All IO is async and you cannot have sync promises actually. You code is 100% async and await
and async
keywords are processed by babel which generates promise code at the end, so no difference
@skottk have you tried running vanilla js RN app? Does it work?
Not a guarantee at all, but there is a possibility my company may be contracting out some iOS app development in the reasonably near future. Not sure of scope or anything like that, but it should be reasonably simple and would be created from scratch. Is anyone here interested in discussing something like that if it does come to pass?