Fork me on GitHub
#clojurescript
<
2016-10-12
>
dnolen00:10:43

@arohner that’s not actually how it works at the moment

dnolen00:10:15

the current support is about making it simpler to use macro and runtime namespaces together (same name)

dnolen00:10:44

if you only have macro ns that’s not going to work - you do need :require-macros

dnolen00:10:59

@arohner there’s no particular reason it doesn’t work other than haven’t done that work yet - probably would be pretty simple.

herbm04:10:48

Not even sure where to ask for help: re-natal om-next react native on Android (and doing it from Windows dev box). Get app running with "react-native run-android" but if instead I use "lein figwheel android" I get all the way to the "Prompt will show when figwheel connects..." but so far no connection has occured that way. Also if I try cider-jack-in-clojurescript the repl appears in emacs but can find no evidence it is connected to the running app (clojure.repl/dir mmynamespace) returns nothing but nil.) I could work with the react-native reload but have heard figwheel is the way to go...

ag05:10:17

@herbm check the log - when figwheel starts it says something “starting figwheel for profile bla-bla”. the cljsbuild profile you’re running should match

ag05:10:36

cider-jack-in-clojurescript does not know anything about figwheel - you have to explicitly tell it by setting these variables: cider-lein-parameters and cider-cljs-lein-repl

ag05:10:50

it’s documented somewhere

ag05:10:36

for example, if your command that starts figwheel in clojure repl is (start) and to start cljs repl (repl) you can tell cider to run those commands immediately when you do cider-jack-in-clojurescript.

ag05:10:37

one convenient way we found is to put it into Emacs local dir vars

ag05:10:20

create file dir-locals.el and put something like this

((nil . ((cider-lein-parameters . "do clean, repl :headless")
         (cider-cljs-lein-repl . "(start) (repl)"))))

herbm05:10:38

thx ag, gives me something to at least try to work and understand -- fairly new to all this as you can easily tell.

Adam Munoz05:10:07

@herbm Can you connect through lein repl?

lauri05:10:28

@herbm there is also a #cljsrn channel

herbm06:10:53

Thx all! -- @adammunoz "lein repl" starts; use figwheel no-errors (simply returns nil); (start-figwheell!) initially complained about port in use until I stopped another one that was still 'waiting' (good sign) but then it gave no errors (nil return). However, trying to swap! app-state throw exception "Unable to resolve symbol: app-state" @lauri was looking for #cljsrn -- thx -- @bhauman got that, but react-native is as least able to reload the app fairly quickly.

Adam Munoz06:10:59

@herbm after (start-figwheel!) have you run (cljs-repl) ?

herbm06:10:19

no, didn't try that till now @adammunoz -- failed but what namespace has cljs-repl ?? might be in wrong one now and need to quality it...?

Adam Munoz06:10:15

It's easy to miss but in the figwheel documentation the correct procedure is:

Adam Munoz06:10:17

(use 'figwheel-sidecar.repl-api)

Adam Munoz06:10:26

(start-figwheel!)

Adam Munoz06:10:55

After that your repl should be ready

Adam Munoz06:10:13

the namespace it's the same as start-figwheel!

herbm06:10:02

I did miss it first time @adammunoz -- had to restart lein repl to do (cljs-repl) then changed to my app ns and still it didn't fine my app-state (and I check the ns and the app-state name in the template project source)

herbm06:10:04

btw, I do NOT get the expected messages when doing (start-figwheel!) either -- just nil

alex-glv06:10:24

Hey, anybody could point me to the right place. When running figwheel with cider / emacs, I do :cljs/quit, then I stop the system components, reload the code, start figwheel again. Initial compilation goes fine, then it throws NPE. I try to reset-autobuild, wipe the target/ and out/ but nothing resolves the issue until I restart the JVM.

alex-glv06:10:36

boards-io.core> :cljs/quit
nil
boards-io.core> (s/system-stop)
#<SystemMap>
[cider refresh here]
boards-io.core> (s/system-start)
#<SystemMap>
boards-io.core> (ra/start-figwheel!)
[…]
Successfully compiled "resources/public/js/main.js" in 0.908 seconds.
nil
Then, I go to change a cljs file, and the first NPE
java.lang.NullPointerException :  at line 7 src/cljs/boards_io/components.cljs
On line 7 is (defui…) macro from om.

herbm08:10:27

My problem was solve by adding: re-natal use-android-device avd before: re-natal use-figwheel then restarting everything, running the packager then repl and changing a difference in the swap! command I found on the natal page. Live figwheel REPL to Android for me. Thx folks.

herbm08:10:21

For an absolute beginner at Om/Om-next are any of the Om resource useful (more of them) in learning to use Om-Next? (And presumably Om-Next is the way to go???)

anmonteiro08:10:05

@herbm: Om and Om Next are very different, the learning resources don't overlap

anmonteiro09:10:02

Om Next is being actively developed, and probably the (only) one getting support in the future

anmonteiro09:10:19

Come hang out with us in #om and feel free to ask any questions

tengstrand11:10:02

I want to be able to change a variable/constants in a ClojureScript project based on the target environment (prod, test, dev). I have found https://crossclj.info/fun/cljs.core/goog-define.html, but I don’t know how to pass the parameter :closure-defines to the compiler. I use Leiningen.

tengstrand11:10:53

I will answer myself. I think I can find the answer here: https://github.com/emezeske/lein-cljsbuild.

darwin11:10:24

@teng when I need to tweak something outside cljs-build map, I tend to use lein’s profiles for separating configurations for independent lein tasks, and for exporting configuration to clojurescript I tend to use macros which emit some literals, not goog-defines

darwin12:10:36

you could write: (def api-uri (emit-api-uri)), where emit-api-uri is a macro returning a string, macros may use full Clojure powers, so they can touch environment, read files on the disk etc., a little known technique is to piggy-back on cljs compiler options and store your own config in there: https://github.com/binaryage/cljs-devtools/blob/f655583627274a08da2e153dbbb70542b4a4ccb4/src/lib/devtools/preload.clj#L6

darwin12:10:37

in your specific case you could do something like: (defmacro emit-api-uri [] (get-in @cljs.env/*compiler* [:options :external-config :my-app/api-uri]))

darwin12:10:38

and then have :profiles {:dev {:cljsbuild {:builds {:client {:compiler {:external-config {:my-app/api-uri "}}}}}}}

darwin12:10:54

or something similar

tengstrand12:10:12

@darwin Thank you! Clojure is awesome!

darwin12:10:22

btw. I would recommend :my-app/config map “convention", later you can add more stuff in the config map

darwin12:10:09

my libraries use this technique, cljs-devtools, dirac, cljs-oops, you can have a look

darwin12:10:32

you can even check what compiler options you currently have, and configure your app based on this, e.g. using something like this: https://github.com/binaryage/cljs-oops/blob/master/src/lib/oops/config.clj#L18-L20

darwin12:10:13

but never cache anything in such macros, always do full job of dereferencing cljs.env/*compiler*

emil0r12:10:17

does anyone know how to remove a node with https://github.com/ckirkendall/kioo ?

emil0r12:10:37

in enlive you do it with passing in nil as the ‘function’ to the selector

emil0r12:10:49

does not appear to work the same in kioo

emil0r12:10:17

hmmm… could write a function that takes the node and returns nil

emil0r12:10:41

@ckirkendall is this by design or just something missing from the library?

ckirkendall12:10:40

that should remove the node

emil0r12:10:05

ok. why not just have nil like enlive though?

ckirkendall12:10:21

I don’t see any issues with supporting that. I just didn’t think about that case when putting together the compiler.

emil0r12:10:54

ok. pr welcome?

emil0r12:10:17

ok. i’ll take a look at in a couple of weeks

rastandy16:10:42

hello everyone

rastandy16:10:54

I have a cljs.spec question:

rastandy16:10:04

do you see something wrong with this spec?

rastandy16:10:27

(s/def :bbox/bbox (s/and (s/keys :req-un [:geo/north :geo/south :geo/east :geo/west]) #(<= (- (:east %) (:west %)) 360)))

rastandy16:10:54

@jrheard thank for looking at this

jrheard17:10:53

fwiw rastandy, i haven’t been able to find anything wrong with it

jrheard17:10:04

what behavior have you been seeing that makes you ask if there’s something wrong with it?

rastandy17:10:39

@jrhead I’ll upload the entire file

rastandy17:10:29

Sorry, wrong snippet

rastandy17:10:12

(s/explain :bbox/bbox {:north -90 :south 90, :east 180 :west -180}) val: {:north -90, :south 90, :east [:positive-lat 180], :west [:negative-lat -180]} fails spec: :bbox/bbox predicate: (<= (- (:east %) (:west %)) 360)

jrheard17:10:19

hm, i get:

(s/explain :bbox/bbox
           {:north -90 :south 90,
            :east 180 :west -180})
nil
=> Success!

rastandy17:10:47

wow, which versione of clojsurescript?

jrheard17:10:52

resetting my repl in case i had some weird state

rastandy17:10:15

I’m on 1.9.89

rastandy17:10:22

need for an upgrade? 😄

rastandy17:10:30

@jrhead thanks for testing it

jrheard17:10:33

seems possible, yeah! 😄 np

jrheard17:10:10

yeah, i reset my repl and it still checks out just fine, hopefully the upgrade fixes it!

rastandy17:10:51

@jrheard great, thank you again!

arohner20:10:47

I have a .cljc file that defines a macro, the macro calls a function during macroexpansion. I’d like to call the macro from both .clj and .cljs. If the function gets called during a .cljs macro expand, rather than a .clj macroexpand, how do I detect that? It appears that the fn always gets called with .clj

arohner20:10:22

(defn foo [x] (println #?(:clj “clj” :cljs “cljs”))) (defmacro bar (foo))

moxaj20:10:04

@arohner I believe (boolean (:ns &env)) will be true inside your macro only if you are compiling cljs

arohner20:10:55

yeah, SO says check for clojurescript-version

anmonteiro20:10:54

and a few other libraries

shaun-mahood21:10:40

What's the best option for converting and storing data CLJS data structures in localstorage? Right now I'm just saving it out as a string and converting it back with cljs.reader/read-string, but it's starting to throw errors on some data that I think should be valid. Before I go through the data I figured I should check if my approach is even reasonable.

dnolen21:10:35

@shaun-mahood EDN is fine, but you need to make sure everything is actual writable to EDN

dnolen21:10:55

no random JS types for example

shaun-mahood21:10:28

It should all be valid data as far as I can tell. Is cljs.reader the best option for this kind of thing? I see that there's also cljs.tools.reader but I have this vague recollection that one is preferred over the other.

dnolen21:10:11

cljs.tools.reader is probably more complete (it does much more than just read EDN)

dnolen21:10:34

“starting to throw errors” is not very informative - so I can’t offer any ideas about what’s wrong with using the built in reader

dnolen21:10:26

we may in fact defer to cljs.tools.reader for cljs.reader at some point, but not there yet

shaun-mahood21:10:31

Ok great, thanks. I'll try both and see which I prefer. I mostly wanted to validate that my whole approach isn't wrong, so if I need more substantial help I'll give you a real error message with a minimal case 🙂 I may experiment a bit with transit as well since it really doesn't have to be long term storage - it's a pretty unimportant cache that probably has few real world benefits and is mainly an excuse to try things I haven't needed to.

anmonteiro21:10:26

@shaun-mahood you might also want to store your data as Transit for faster conversion and less JSON size

shaun-mahood22:10:09

@anmonteiro: Yeah, I think that's going to be my first avenue to try out. It's one of the libraries that I haven't needed to use yet but have wanted to for a long time.

tomjkidd22:10:34

@shaun-mahood http://cognitect.com/events/webinars Bridging Language Barriers with Transit is a good resource

tomjkidd22:10:40

Yeah, that webinar is really useful

shaun-mahood22:10:09

@dnolen: Everything is working perfectly with transit using the same data that fails with cljs.reader - Transit code: (transit/read (transit/reader :json) (transit/write (transit/writer :json) test-data)) Reader code: (cljs.reader/read-string (str test-data)) Error message on reader is

(cljs.reader/read-string (str test-data))
#object[TypeError TypeError: Cannot read property '0' of null]
   cljs$reader$read_keyword (jar:file:/C:/Users/smahood/.m2/repository/org/clojure/clojurescript/1.9.229/clojurescript-1.9.229.jar!/cljs/reader.cljs:367:21)
   cljs.reader/read-delimited-list (jar:file:/C:/Users/smahood/.m2/repository/org/clojure/clojurescript/1.9.229/clojurescript-1.9.229.jar!/cljs/reader.cljs:233:23)
   cljs$reader$read_map (jar:file:/C:/Users/smahood/.m2/repository/org/clojure/clojurescript/1.9.229/clojurescript-1.9.229.jar!/cljs/reader.cljs:284:12)
   cljs.reader/read-delimited-list (jar:file:/C:/Users/smahood/.m2/repository/org/clojure/clojurescript/1.9.229/clojurescript-1.9.229.jar!/cljs/reader.cljs:233:23)
   cljs$reader$read_vector (jar:file:/C:/Users/smahood/.m2/repository/org/clojure/clojurescript/1.9.229/clojurescript-1.9.229.jar!/cljs/reader.cljs:280:9)
   cljs.reader/read-delimited-list (jar:file:/C:/Users/smahood/.m2/repository/org/clojure/clojurescript/1.9.229/clojurescript-1.9.229.jar!/cljs/reader.cljs:233:23)
   cljs$reader$read_map (jar:file:/C:/Users/smahood/.m2/repository/org/clojure/clojurescript/1.9.229/clojurescript-1.9.229.jar!/cljs/reader.cljs:284:12)
   cljs.reader/read-delimited-list (jar:file:/C:/Users/smahood/.m2/repository/org/clojure/clojurescript/1.9.229/clojurescript-1.9.229.jar!/cljs/reader.cljs:233:23)
   cljs$reader$read_map (jar:file:/C:/Users/smahood/.m2/repository/org/clojure/clojurescript/1.9.229/clojurescript-1.9.229.jar!/cljs/reader.cljs:284:12)
   cljs$reader$read_delimited_list (jar:file:/C:/Users/smahood/.m2/repository/org/clojure/clojurescript/1.9.229/clojurescript-1.9.229.jar!/cljs/reader.cljs:233:23)
Think it's worthwhile for me to track down the piece of data that fails and file a bug report? I can just use transit so my problem is solved, but if this seems like bad behaviour for the reader then I'm happy to try and figure out what's going on.

dnolen22:10:48

@shaun-mahood yes a report is preferred

dnolen22:10:08

@shaun-mahood though the error seems to suggest you are trying to read :

dnolen22:10:48

I don’t believe that’s a valid keyword, but will need to review what Clojure documentation states

shaun-mahood23:10:39

@dnolen: Ok, I've figured out what data it's failing on - I'm pretty sure this is an expected failure, Cursive throws an error if I try to define it in the REPL too. (cljs.reader/read-string (str {:path :docs/}))

dnolen23:10:45

right that’s not going to work

mx200023:10:23

VIM and fireplace with lein fighweel. After :Connect <nrepl://localhost:7888> and :Piggieback I get the following error trying to eval anything: org.mozilla.javascript.EcmaError: TypeError: Cannot call method "getStackTrace" of undefined (rhino.clj#41)^@'