Fork me on GitHub
#cljsrn
<
2021-07-06
>
woonki.moon00:07:29

I'm using the Krell. Whenever I add a file(*.cljs) in my project, I should re-run the commands clj -M -m krell.main -co build.edn -c clj -M -m krell.main -co build.edn -r respectively. Krell seems can't find the new added file without it. I'm very new to clj(s), so probably I'm missing something. Is there any way to make this flow better?

gammarray03:07:31

I noticed the same thing recently. Also wondering if there is a better way?

2
pez17:07:43

So, @anthony-galea and I managed to reproduce that ^ hot-reload freeze bug in a minimal cljsrn project. It is just a matter of def-ing enough data structures and then hot-reload. I can make it reliably happen with shadow-cljs, but haven’t been able to make it happen with Krell. Here’s the repro project: https://github.com/PEZ/AndroidCljsrnHotreloadFreeze

pez17:07:22

It might happen only with the debugger, but I am not sure that is needed. I’ll try with even more data and see if I can provoke it w/o the debugger.

pez17:07:36

In one releaase build of our work project app, we had an exact same freeze (symptoms bug) so it might not have to do with hot-reload either.

thheller17:07:55

only guess I have is that shadow will send all files over the websocket. maybe android doesn't like big messages like that?

pez17:07:51

Does it send them one by one, or as one message?

thheller17:07:14

one message

thheller17:07:20

why do you have such gigantic maps in your code? wouldn't it make more sense to keep it out of the code and load it dynamically?

pez17:07:48

It’s a bad legacy move. We really should move that map out of the project for a lot of reasons. However, our map is just one, and not this big. I don’t think the freeze is about the size of this map. Rather about the size of our project. Our big map just makes this happen earlier. Well, at least that’s what I think from having experimented with this for a while.

thheller17:07:04

> I can see that Shadow and Krell choose to reload different sets of files

thheller17:07:30

how so? I mean there aren't that many files to reload? 😛

pez17:07:17

It was just an observation. ¯\(ツ)

pez17:07:57

But you remind me that the map files do not need to be reloaded for the freeze to happen. Only core.cljs is reloaded here, for instance:

load JS awesome_project/core.cljs
call awesome-project.core/start
[React DevTools] Connection to RN closed

pez07:07:48

So that would falsify the “big message” theory, right?

dnolen18:07:24

@woonki.moon and you required this new file in some namespace?

woonki.moon23:07:32

Yes, for example, I added foo.cljs and I required this new file in the namespace home which is already exists. The metro bundler keeps complaining like this. It doesn't disappear until I run the commands clj -M -m krell.main -co build.edn -c

Michael Jung20:07:14

@dnolen Some time ago I was asking about whether Krell supports specially annotated functions that are executed after a hot reload of the app (like shadow-cljs does). I wanted to use that to get proper hot reloading in my app that uses react navigation. I managed to find a solution that works for me and wanted to come back to this and let you know how I was able to do it with the help of such a function. The main idea is not my own, I found it in some blog post on the internet. After switching to shadow-cljs I added the following to my main cljs file:

(defonce component-to-update (atom nil))

(def updatable-app-root
  (with-meta app-root
    {:component-did-mount
     (fn [] (this-as ^js this
                     (reset! component-to-update this)))}))

(defn reload {:dev/after-load true} []
  (.forceUpdate ^js @component-to-update))

(defn init []
  (dispatch-sync [:initialize-db {}])
  (load-db-from-storage)
  (.registerComponent AppRegistry "MyApp" #(r/reactify-component updatable-app-root)))
So I run .forceUpdate on the root component after every reload. This will trigger a re-render of the root component which in turn will trigger some code that will recreate the navigation state from what is stored in the app-db (whenever I navigate to some other screen I store some information about this change in the app-db so I can always use it to recreate the state). When I now do any code changes to some inner component, they are reflected on the device immediately.

👍 2
niveauverleih23:07:12

What tooling do you recommend if I want to create a cljs react native mobile app ON my Android mobile? I am new to this and I want to learn by playing around. What is working so far: I have Doom emacs installed on termux, I have java, cider, clj-kondo lsp. I can compile clojure programs, and I was also able to reproduce the clojureScript examples in Carin Meiers book. "Living Clojure". I can install npm and some people reported that expo can be installed. The constraint is that I can't install the Android SDK. The idea is to produce an apk and to install it from time to time.