Fork me on GitHub
#cljsrn
<
2017-01-12
>
edwthomas04:01:09

For my app, I assumed I would use cljs-ajax and but I couldn’t get a simple GET to work. I was forced to use js/fetch. This was a problem specifically on Android (I didn’t test on iOS).

levitanong04:01:10

cljs-ajax works on iOS for me

ejelome06:01:08

@levitanong you sure will 😛

ejelome07:01:01

in the react native tutorial, there are three ways to do networking, there's fetch, xmlhttprequest, and websocket

ejelome07:01:22

I went back to the gui part for now so I might ask on a later time XD

pesterhazy12:01:07

It's true, cljs ajax doesn't work on android

ejelome20:01:36

hmmm ... what's the equivalent of onChangeText attribute in re-natal? :on-change-text doesn't seem to work

ejelome21:01:40

not working unfortunately 😞

raspasov21:01:39

@ejelome it should be :onChangeText

raspasov21:01:08

as far as I know re-natal doesn’t do any dasherizing etc

raspasov21:01:57

@ejelome I’ve been using cljs-http with React Native - works nice

ejelome21:01:12

will note that cljs-http

ejelome21:01:39

the :on-change-text works, but the parameter part is causing an error

raspasov21:01:23

what’s the error?

ejelome21:01:05

reset! is undefined

ejelome21:01:22

I can't type it because it's in an emulator XD

raspasov21:01:54

woah, ok, seems weird, if you have a gist might be able to give better ideas

ejelome21:01:58

undefined is not a function ... cljs.core.reset_BANG_call ...

ejelome21:01:34

this is the code:

(defn pizza-translator []
  (let [char (r/atom "")]
    (fn []
      [view {:style {:padding 10}}
       [text-input
        {:style {:height 40}
         :placeholder "Type here to translate!"
         :on-change-text #(% (reset! char %))}]])))

ejelome21:01:50

it's simply a replica of the jsx version

ejelome21:01:56

but I'm stuck on the on-change-text

raspasov21:01:28

that’s wrong, I think

ejelome21:01:45

ok, enlighten me pls 😄

raspasov21:01:59

it’s more like

raspasov21:01:14

ok, 1st thing first let’s not use the shorthand 🙂

ejelome21:01:40

correct everything as much as you want, that'll be super helpful

raspasov21:01:16

(fn [x] (println “what is x???” x))

raspasov21:01:26

I think it should be a string

ejelome22:01:16

right, it's a string

ejelome22:01:29

the repl responds as I type

raspasov22:01:16

right, so do you understand the problem now? 🙂

raspasov22:01:39

can’t call a string as a function

raspasov22:01:53

which is what

raspasov22:01:54

#(% (reset! char %))

ejelome22:01:28

w8 a sec I'll try a non shortened

ejelome22:01:51

that's weird

ejelome22:01:01

it works on non-shorthand but doesn't on shorthand

ejelome22:01:48

here:

;; doesn't work
:on-change-text #(% (reset! char %))

;; works:
:on-change-text (fn [this] (reset! char this))

ejelome22:01:59

@raspasov can I have a hint why the shorthand doesn't work? or it's not really equivalent?

raspasov22:01:38

#(reset! char %)

raspasov22:01:51

your shorthand would expand to

raspasov22:01:11

(fn [a-string] (a-string (reset! char a-string)))

raspasov22:01:29

that’s why my recommendation is: until you’ve been using Clojure for a loooong time, don’t use shorthands 🙂

raspasov22:01:44

it can confuse you

ejelome22:01:15

so it's basically a wrong format, hahaha

ejelome22:01:57

awesome! @raspasov thanks for the help :thumbsup: