Fork me on GitHub
#clojurescript
<
2020-12-17
>
Shako Farhad09:12:04

Hey guys. I have setup a shadow-cljs project with deps.edn. When I run the

clj -A:shadow-cljs-dev watch app
command I get a server up and running and things are great. But after I quit it with "ctrl + z" the server lingers forever. I can go to localhost:8700 and still see my app running there. If I restart the watch app then it will says that my build is stale and was not produced by the current watcher. Only workaround is to change the port. Anyone know how to fix this? Reboot doesn't help either. So something is cached somewhere?

p-himik09:12:48

Why do you quit with "Ctrl+Z" and not "Ctrl+C"?

Shako Farhad09:12:21

I did "Ctrl + C" in the beginning and it had the same effect. So I checked the shadow-cljs documentation and I believe there they mentioned ctrl+z. Either way both have the same outcome :/

p-himik09:12:19

Shadow-cljs does not mention "Ctrl+Z". "Ctrl+Z", if you use it in some common terminal without redefining any keys, sends SIGTSTP that suspends the foreground process - it doesn't stop it. In fact, you can bring it back with the fg command (assuming bash-like shell).

p-himik09:12:09

"Ctrl+C" should work with the shadow-cljs executable or with npx shadow-cljs or something like that. Why it doesn't work for you depends on what your :shadow-cljs-dev alias does.

Shako Farhad09:12:48

Hmmm.. I must have confused myself then. >< The alias is this:

:shadow-cljs-dev
  {:extra-deps {thheller/shadow-cljs {:mvn/version "RELEASE"}
                re-frame/re-frame {:mvn/version "1.1.2"}
                binaryage/devtools {:mvn/version "1.0.2"}
                re-frisk/re-frisk {:mvn/version "1.3.5" :exclusions [com.google.code.findbugs/jsr305 
                                                                     re-frame/re-frame]}}
   :main-opts ["-m" "shadow.cljs.devtools.cli"]}

p-himik09:12:16

I would expect "Ctrl+C" to work just fine in this case - I would ask in #shadow-cljs

Shako Farhad09:12:36

Oh I didnt know about that channel. Thanks! šŸ˜„

Michaƫl Salihi14:12:50

Hi ! I wonder to know what's the solution to import ES6 default export in vanilla CLJS since this issue? https://clojure.atlassian.net/browse/CLJS-2376

šŸ™ 3
Michaƫl Salihi08:12:13

@U066TMAKS FYI, I had sucess with experimentation using Shadow-CLJS since it provides :default to import the lib like this

["react-native-alarm-clock" :default AlarmClock]

Michaƫl Salihi08:12:59

For the moment, no success with vanilla CLJS using Krell.

Michaƫl Salihi09:12:40

I think we have to take out our jocker and call for help from @U050B88UR @U04VDQDDY šŸ™‚

Michaƫl Salihi09:12:03

With Krell I tried to import like this but no success

["react-native-alarm-clock" :refer [default] :rename {default AlarmClock}]

Michaƫl Salihi09:12:42

@U050B88UR @U04VDQDDY @U066TMAKS You can ignore my latest posts, it works! I don't know why my tests didn't work but this time it was done in the classic way:

["react-native-alarm-clock" :as clock]

...
(.-default clock)

Michaƫl Salihi09:12:22

So @U066TMAKS The full code you can tried:

(ns awesome-project.core
  (:require [reagent.core :as r]
            [reagent.react-native :as rn]
            ["react-native-alarm-clock" :as clock]))

(defn create []
  (let [date (js/Date.)]
    (.createAlarm (.-default clock) (.toISOString date) "My alarm")))

(defn hello []
  [rn/view {:style {:flex 1 :align-items "center" :justify-content "center"}}
   [rn/text {:style {:font-size 50}} "Hello Krell!"]
   [rn/button {:on-press #(create)
               :title "Add alarm"}]])

(defn ^:export -main [& args]
  (r/as-element [hello]))

Michaƫl Salihi09:12:41

The doc from the ib doesn't mention this, but don't forget to add the alarm permission. Add this line in your ./android/app/src/main/AndroidManifest.xml :

<uses-permission android:name="com.android.alarm.permission.SET_ALARM" />

wei17:12:29

thanks so much for following up Michaƫl! your answers have been really helpful for me getting up and running with cljs + rn.

šŸ‘Œ 3
wei17:12:46

everything worked after adapting your code example and adding the permission to the manifest.

parrot 3
Michaƫl Salihi14:12:20

I do regullary with Shadow-CLJS since it provide :default in ns but vanilla CLJS doesn't adopt it. https://clojure.atlassian.net/browse/CLJS-2376