clojurescript

ClojureScript, a dialect of Clojure that compiles to JavaScript http://clojurescript.org | Currently at 1.10.879
Shako Farhad 2020-12-17T09:28:04.353300Z

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-himik 2020-12-17T09:43:48.353700Z

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

Shako Farhad 2020-12-17T09:45:21.353900Z

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-himik 2020-12-17T09:47:19.354100Z

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-himik 2020-12-17T09:48:09.354300Z

"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 Farhad 2020-12-17T09:56:48.354500Z

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-himik 2020-12-17T09:59:16.354700Z

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

Shako Farhad 2020-12-17T09:59:36.354900Z

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

2020-12-17T14:15:50.357600Z

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

πŸ™ 1
2020-12-18T08:58:13.364500Z

@wei 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]

2020-12-18T08:58:59.364700Z

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

2020-12-18T09:01:40.364900Z

I think we have to take out our jocker and call for help from @dnolen @mfikes πŸ™‚

2020-12-18T09:03:03.365100Z

With Krell I tried to import like this but no success

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

2020-12-18T09:12:42.365300Z

@dnolen @mfikes @wei 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)

2020-12-18T09:13:22.365500Z

So @wei 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 [&amp; args]
  (r/as-element [hello]))

2020-12-18T09:16:41.365800Z

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 :

&lt;uses-permission android:name="com.android.alarm.permission.SET_ALARM" /&gt;

2020-12-19T17:00:29.381200Z

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

πŸ‘Œ 1
2020-12-19T17:35:46.381400Z

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

🦜 1
2020-12-17T14:19:20.359100Z

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