Fork me on GitHub
#shadow-cljs
<
2020-11-08
>
xfyre19:11:55

Does anyone know what this might mean (React Native)?

(shadow/repl :dev-android)
To quit, type: :cljs/quit
=> [:selected :dev-android]
(def one 1)
=> #object[TypeError TypeError: undefined is not an object (evaluating 'cljs.user.one = (1)')]
I’m pretty certain it was working before, so I don’t quite understand what went wrong and why

thheller19:11:27

just a hunch but looks like cljs.user is undefined. do you get the same error for (ns cljs.user) or so?

xfyre20:11:30

oh, interesting. if I execute (ns cljs.user) before anything else - it starts working

thheller20:11:23

which version is this? there was one 2.10 version that had this problem IIRC

thheller20:11:31

can't remember which though

xfyre20:11:09

"shadow-cljs": "^2.11.4"

xfyre20:11:19

it’s no big deal, but I was puzzled

xfyre20:11:30

@thheller btw - regarding hot reload questions I had a couple of weeks earlier. I figured out why recompilation messes up React Native hot reload. That’s because the entry point file target/index.js gets rewritten every time - so at first Metro reacts correctly and tries to do a fast refresh, but then, when entry point file gets updated - it just reloads the whole thing. Although I finally got it to work as you suggested, I’m wondering whether it would be possible to prevent the entry point from getting recompiled every time.

thheller20:11:37

you should disable any hot-reloading from the metro side

xfyre20:11:45

yes, that’s what I did

thheller20:11:50

it is not needed and will only get in the way

xfyre20:11:18

but I’m curious why the entry point file gets recompiled every time

thheller20:11:36

so you always have the latest code on disk

thheller20:11:52

I could disable that but then you'd get old versions if you reloaded the RN app

xfyre20:11:06

you mean this is configurable?

thheller20:11:15

no it isn't. but it could be.

thheller20:11:33

but first I need a convincing reason why it should be 😉

thheller20:11:06

I mean I can't see a scenarion where metro fast refresh and shadow hot-reload won't conflict with each other and mess each other up

xfyre20:11:50

it might make sense to allow choosing one or the other (I don’t have a strong opinion about this - since I never got fast refresh to work, I don’t know how convenient it is compared to shadow hot reload)

zhuxun220:11:05

It seems that the extern inference doesn't work well with the go blocks:

(defn f
  []
  (.-foo (clj->js {"foo" 42})))
;; WARNING: :infer-warning

(defn f
  []
  (.-foo ^js (clj->js {"foo" 42})))
;; no warning

(defn f
  []
  (clojure.core.async/go (.-foo ^js (clj->js {"foo" 42}))))
;; WARNING again :infer-warning

thheller20:11:50

yeah thats a known issue. go rewrites too much stuff and loses typehints

zhuxun220:11:42

Is there a way to hide that particular warning?

thheller20:11:53

I don't know. depends on the actual code. I mean if you actually use clj->js and then access a property that doesn't make sense at all?

thheller21:11:58

you should always have as little code as possible in go blocks so ideally you never get to code that has to do this

zhuxun221:11:26

What I'm actually trying to do is to wrap http://goog.net.XhrIo.send into a channel so that I don't have to do callbacks

thheller21:11:27

don't know if there is an open core.async issue about this

thheller21:11:38

thats fine but you can construct all of it outside a go

zhuxun221:11:52

but using this channel requires the user code to be in a go-block, right? That's where I have other code that needs type-hinting

thheller21:11:00

no it doesnt

thheller21:11:26

I mean waiting on the channel result does yes but not constructing the xhr itself

zhuxun221:11:01

I think this is what I mean:

(go
  (let [url (.getParameterValue parsed-href "url")]
      (<! (fetch-ch url))
      ;; other stuff
  ))

zhuxun221:11:39

yes, fetch-ch itself wont report any warnings

zhuxun221:11:52

but (.getParameterValue parsed-href "url") will

thheller21:11:03

you can make a helper function for that to avoid the . access

thheller21:11:14

(let [url (get-parameter-value parsed-href "url")] ...)

👍 3
thheller21:11:59

I know its annoying but so far no one has dared working on the core.async code

thheller21:11:36

its not something I can work arround in shadow-cljs

thheller21:11:00

if you don't care about inference you get (set! *warn-on-infer* false) in that file

zhuxun221:11:46

I see. Yeah I guess that's one workaround