Fork me on GitHub

if a library provides a deftype and some protocols that type might inherit, what is the “hook” they should also expose so you, as the consumer, can provide your own type’s varying implementation of those protocols? do you take in the type to create as a parameter? do you take a created type instance and operate only via protocols on that (who knows?) type?


if a lib doesnt expose an extensible protocol / type properly, how unwise would it be to alter-var-root on their constructor and shimmy-in your own type/protocol impls?


I have a website built in CLJS using reagent. I’m having a problem with password fields, where the :change event isn’t fired for password fields filled in by the PwdHash browser plugin. I thought it was the order of the :change and :blur events that was the problem, messing up my validation, but it seems that I’m not getting the :change event at all. Any suggestions for dealing with this?


I worked around this by using the :blur event to copy the field value to the app state atom and validating it at that point.


IIUC re-seq does two searches for each match of the regexp in the searched string?


wouldn't it be faster to use the .-index of the result of .execing the regular expression?


or is that not portable or otherwise wrong?


cljs.user> (let [m (.exec #"br\w+" "the quick brown fox yadda yadda")]
             {:index (.-index m) :text (aget m 0)})
{:index 10, :text "brown"}


@euccastro if the above is a performance win I guess it could be added with some profiling to core? I guess it should be thoroughly tested maybe? Looks good to see it this way - the only thing to avoid being using aget for objects - it is frowned up 😄


Nah, aget is for arrays 🙂

🙏 4

It is the use of aget to access object properties that is the oddity


@mfikes: fair enough, but the use of aref is besides my point. this works too:

cljs.user> (let [m (.exec #"br\w+" "the quick brown fox yadda yadda")]
             {:index (.-index m) :text (first m)})
{:index 10, :text "brown"}


Ah right I thought it was an map object up there :)


I must be very tired ;)


@euccastro I was saying that aget is correct to use on m in that case—m is #js ["brown"]

👍 4

Yep ☝️ sorry


@euccastro If you end up being interested in contributing a perf improvement, there is lots of info here, but ask, and especially in #cljs-dev if you have questions


I'll give it a try, thanks! I'm not sure it will be a big win, but unless there are other considerations I'm missing, I can't see how searching once can be slower than searching twice for the same thing 🙂

Abstract Armen08:07:33

Hey guys! I'm using pushy for HTML5 pushState ( In my project, I need to navigate back to previous route and usually I use history.back(). I've found anything about that in pushy documentation. Any ideas?


I think just use window.history object, [:a {:on-click #(js/window.history.back) :href "#"} "Back"]


I’m a big fan of figwheel, but I recently heard about browserSync (something similar for JS?), which I’ve really not used. Is it comparable? Which came first?


Correction: recently in this space after reporting #reagent’s susceptibility to glitches I surmised that #re-frame subscriptions would inherit that edge vulnerability. After some fairly abusive testing, it seems not. r/f subs are their own beast, leveraging ratoms but implementing their own glitch-less data flow. Nice!

🎉 8

How can I prevent

SEVERE: ERROR - Duplicate extern input: file:/Users/erooijak/.m2/repository/cljsjs/iota-mam/0.0.1-0/iota-mam-0.0.1-0.jar!/cljsjs/iota/common/iota.ext.js

Jul 25, 2018 3:14:34 PM printSummary
WARNING: 1 error(s), 0 warning(s)
ERROR: JSC_DUPLICATE_EXTERN_INPUT. Duplicate extern input: file:/Users/erooijak/.m2/repository/cljsjs/iota-mam/0.0.1-0/iota-mam-0.0.1-0.jar!/cljsjs/iota/common/iota.ext.js at (unknown source) line (unknown line) : (unknown column)
? 🙂


I tried:

[cljs-iota "1.0.1"]
[cljs-iota-mam "1.0.7" :exclusions [cljsjs/iota]]
But that’s not enough.


@erwinrooijakkers can you just skip cljs-iota and use cljs-iota-mam only


@jmckitrick they are different things

João Lucas13:07:24

I wonder if anyone has used the jQuery plugin 'fullcalendar' on their clojuscript app. As it isn't listed on cljsjs, I'd like to know what to keep in mind in order to use it.


Thanks @bhauman but then the same error appears strangely enough. Maybe because I published the library locally as well.


So it would not be ignorant of me to pitch figwheel to my team by saying JS has no equivalent ATM?


You do have state-preserving hot code reloading in React for example via But then you don’t have a REPL nor write in ClojureScript.


there's a suite of bhauman tools that make life amazing for me. I run: cljs-test-display, devcards, site. The test display runs unit tests and gives me favicon display of passing/failing state. devcards so i build my components and can interact with them. this forces me to code in a certain style that makes things more easy to use. and then finally plug into the real app and hook up the IO or whatever


When I use

[cljs-iota-mam "1.0.7" :exclusions [cljsjs/iota]] ;; no cljs-iota
I get the error: >Compiling [“resources/public/js/compiled/app.js”] failed. >clojure.lang.ExceptionInfo: failed compiling file:target/cljsbuild-compiler-1/cljs_iota/core.cljs {:file #object[ 0x44473eed “target/cljsbuild-compiler-1/cljs_iota/core.cljs”]} When I use
[cljs-iota-mam "1.0.7"] ;; no cljs-iota
I get the same error as with including both cljs-iota and cljs-iota-mam >>>SEVERE: ERROR - Duplicate extern input: file:/Users/erooijak/.m2/repository/cljsjs/iota-mam/0.0.1-0/iota-mam-0.0.1-0.jar!/cljsjs/iota/common/iota.ext.js Jul 25, 2018 3:52:14 PM printSummary WARNING: 1 error(s), 0 warning(s) ERROR: JSC_DUPLICATE_EXTERN_INPUT. Duplicate extern input: file:/Users/erooijak/.m2/repository/cljsjs/iota-mam/0.0.1-0/iota-mam-0.0.1-0.jar!/cljsjs/iota/common/iota.ext.js at (unknown source) line (unknown line) : (unknown column)


Hmm maybe the problem is that both packages have the same externs file name in cljsjs/packages:

$ find . -name "iota.ext.js"


Just having both a dependency on cljsjs/iota


@jmckitrick I’d be careful about overstating the uniqueness of the repl & hotloading. Try out create-react-app and tell me that’s not pretty slick. The hotloading is just as responsive if not more because the development version of a js stack tends to push less code that cljs. Javascript has a repl and browsers have a console you can jump right into. There was a conversation about why cljs repls are more powerful, but I found it to be splitting hairs. I jump into to a js repl pretty often and use it for similar types of experiments. Cljs is really better suited for repl experimentation, but explaining why is hard.


@lee.justin.m in my experience, explaining is hard but showing how to do it seems to have better results. I, for instance, use Atom for development, and the experience that I always miss on other languages/frameworks is when I have some private part of my code that is failing. On React, I need to make that part of the code public (probably using something like = myPrivateFun), then experiment in the JS console. In CLJS, I just open in Atom my file, add a def inside the private fn to see what are the parameters that are breaking, then without exiting Atom, start to experiment different values.


Then, after I find out why it's failing, it's just a matter of converting it to a testcase and fix the function


@mauricio.szabo right so it seems to me it isn’t that the repl is better. its that cljs is a language that is better suited to repl experimentation. a skeptic is not going to see the difference between the js repl and the cljs repl, but they should see that the langauges are very different


As JS tools become more advanced, I sometimes feel like I’m losing the battle for CLJS. 😕


the most honest argument is that cljs is no worse but it is more fun


I’ve converted 2 colleagues so far, and they use similar words: fun, refreshing, etc


I try to use cljsjs.react-bootstrap, but get No such namespace: cljsjs.react-bootstrap, could not locate ... error. My :dependencies are:

[cljsjs/bootstrap "3.3.6-1"]
[cljsjs/react-bootstrap "0.31.5-0"]
My ns declaration is:
(ns my-app.bootstrap
  (:require [reagent.core :as r]
What do I miss?


how do I quickly check validity of uuid?

cljs.user> (uuid? (uuid "foo"))

👎 4

preferably without having to use regex


does anybody understand why cljs-devtools says that :a is null when I eval this (js/console.log {:a false}) even though it prints false when I eval (js/console.log false)


@ag a brief look at the source indicates that there isn’t any validation code you can use. you might just install uuid-validate from npm, which is pretty complete in terms of being aware of the different uuid specs and is only 100 lines of js (though ultimately it uses a regex)