Fork me on GitHub
#clojurescript
<
2018-07-25
>
lwhorton00:07:07

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?

lwhorton00:07:48

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?

cfleming00:07:18

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?

cfleming01:07:19

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.

euccastro01:07:45

IIUC re-seq does two searches for each match of the regexp in the searched string? https://cljs.github.io/api/cljs.core/re-seq

euccastro01:07:57

wouldn't it be faster to use the .-index of the result of .execing the regular expression? https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec

euccastro01:07:07

or is that not portable or otherwise wrong?

euccastro01:07:52

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

richiardiandrea01:07:15

@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 😄

mfikes01:07:42

Nah, aget is for arrays 🙂

🙏 4
mfikes01:07:46

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

euccastro01:07:06

@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"}

richiardiandrea01:07:11

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

richiardiandrea01:07:36

I must be very tired ;)

mfikes01:07:27

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

👍 4
richiardiandrea01:07:02

Yep ☝️ sorry

mfikes01:07:28

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

euccastro01:07:22

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 (https://github.com/kibu-australia/pushy). 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?

digioi15:07:04

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

jmckitrick13:07:16

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?

kennytilton13:07:46

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
erwinrooijakkers13:07:26

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 com.google.javascript.jscomp.LoggerErrorManager 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)
? 🙂

erwinrooijakkers13:07:49

I tried:

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

bhauman13:07:11

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

bhauman13:07:11

@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.

erwinrooijakkers13:07:01

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

jmckitrick13:07:22

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

erwinrooijakkers13:07:52

You do have state-preserving hot code reloading in React for example via https://github.com/gaearon/react-hot-loader. But then you don’t have a REPL nor write in ClojureScript.

dpsutton13:07:34

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

erwinrooijakkers13:07:31

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[java.io.File 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 com.google.javascript.jscomp.LoggerErrorManager 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)

erwinrooijakkers13:07:29

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

$ find . -name "iota.ext.js"
./iota/target/cljsjs/iota/common/iota.ext.js
./iota/resources/cljsjs/iota/common/iota.ext.js
./iota-mam/target/cljsjs/iota/common/iota.ext.js
./iota-mam/resources/cljsjs/iota/common/iota.ext.js

erwinrooijakkers13:07:14

Just having both a dependency on cljsjs/iota

justinlee15:07:27

@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.

mauricio.szabo15:07:00

@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.

mauricio.szabo15:07:35

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

justinlee15:07:09

@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

jmckitrick15:07:50

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

justinlee15:07:14

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

jmckitrick15:07:09

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

felbit16:07:09

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]
            cljsjs.react-bootstrap))
What do I miss?

ag18:07:39

how do I quickly check validity of uuid?

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

👎 4
ag18:07:50

preferably without having to use regex

justinlee23:07:16

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)

justinlee23:07:52

@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)