This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-10-12
Channels
- # beginners (34)
- # boot (210)
- # cider (16)
- # cljs-dev (65)
- # cljsrn (3)
- # clojars (2)
- # clojure (107)
- # clojure-austin (8)
- # clojure-berlin (10)
- # clojure-brasil (1)
- # clojure-canada (1)
- # clojure-dev (1)
- # clojure-fr (1)
- # clojure-italy (22)
- # clojure-new-zealand (12)
- # clojure-nl (28)
- # clojure-russia (13)
- # clojure-spec (25)
- # clojure-uk (10)
- # clojurescript (109)
- # cursive (18)
- # datomic (44)
- # defnpodcast (1)
- # dirac (4)
- # emacs (2)
- # funcool (1)
- # hoplon (16)
- # jobs (14)
- # lambdaisland (23)
- # leiningen (2)
- # luminus (3)
- # off-topic (7)
- # om (58)
- # onyx (16)
- # proton (6)
- # re-frame (42)
- # reagent (55)
- # ring-swagger (5)
- # untangled (47)
- # vim (9)
the current support is about making it simpler to use macro and runtime namespaces together (same name)
@arohner there’s no particular reason it doesn’t work other than haven’t done that work yet - probably would be pretty simple.
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...
@herbm check the log - when figwheel starts it says something “starting figwheel for profile bla-bla”. the cljsbuild profile you’re running should match
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
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.
create file dir-locals.el
and put something like this
((nil . ((cider-lein-parameters . "do clean, repl :headless")
(cider-cljs-lein-repl . "(start) (repl)"))))
thx ag, gives me something to at least try to work and understand -- fairly new to all this as you can easily tell.
@herbm Can you connect through lein repl?
if you can you can run figwheel inside that repl like https://github.com/bhauman/lein-figwheel/wiki/Using-the-Figwheel-REPL-within-NRepl
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.
@herbm after (start-figwheel!) have you run (cljs-repl) ?
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...?
It's easy to miss but in the figwheel documentation the correct procedure is:
(use 'figwheel-sidecar.repl-api)
(start-figwheel!)
(cljs-repl)
After that your repl should be ready
the namespace it's the same as start-figwheel!
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)
btw, I do NOT get the expected messages when doing (start-figwheel!) either -- just nil
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.
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.Ah, read the reloading workflow and caveats page https://github.com/clojure/tools.namespace#reloading-code-preparing-your-application
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.
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???)
@herbm: Om and Om Next are very different, the learning resources don't overlap
Om Next is being actively developed, and probably the (only) one getting support in the future
Come hang out with us in #om and feel free to ask any questions
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.
I will answer myself. I think I can find the answer here: https://github.com/emezeske/lein-cljsbuild.
@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
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
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]))
and then have :profiles {:dev {:cljsbuild {:builds {:client {:compiler {:external-config {:my-app/api-uri "
@darwin Thank you! Clojure is awesome!
btw. I would recommend :my-app/config
map “convention", later you can add more stuff in the config map
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
but never cache anything in such macros, always do full job of dereferencing cljs.env/*compiler*
does anyone know how to remove a node with https://github.com/ckirkendall/kioo ?
@ckirkendall is this by design or just something missing from the library?
@emil0r (substitue nil)
that should remove the node
I don’t see any issues with supporting that. I just didn’t think about that case when putting together the compiler.
very much so
(s/def :bbox/bbox (s/and (s/keys :req-un [:geo/north :geo/south :geo/east :geo/west]) #(<= (- (:east %) (:west %)) 360)))
what behavior have you been seeing that makes you ask if there’s something wrong with it?
(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)
hm, i get:
(s/explain :bbox/bbox
{:north -90 :south 90,
:east 180 :west -180})
nil
=> Success!
yeah, i reset my repl and it still checks out just fine, hopefully the upgrade fixes it!
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
@arohner I believe (boolean (:ns &env))
will be true inside your macro only if you are compiling cljs
@arohner the approach @moxaj mentioned is what Schema uses too: https://github.com/plumatic/schema/blob/master/src/clj/schema/macros.clj#L10-L19
and a few other libraries
@arohner there’s also a longer discussion about that here: https://groups.google.com/forum/#!searchin/clojurescript/macro$20clojurescript$20ns$20env%7Csort:relevance/clojurescript/iBY5HaQda4A/SuVYqNRH8gwJ
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.
@shaun-mahood EDN is fine, but you need to make sure everything is actual writable to EDN
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.
“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
we may in fact defer to cljs.tools.reader
for cljs.reader
at some point, but not there yet
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.
@shaun-mahood you might also want to store your data as Transit for faster conversion and less JSON size
@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.
@shaun-mahood http://cognitect.com/events/webinars Bridging Language Barriers with Transit is a good resource
@tomjkidd: Thanks!
@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.@shaun-mahood yes a report is preferred
@shaun-mahood though the error seems to suggest you are trying to read :
I don’t believe that’s a valid keyword, but will need to review what Clojure documentation states
@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/