Fork me on GitHub
#clojurescript
<
2017-02-10
>
emccue02:02:57

@borkdude goog.Promise docs cite itself as being not entirely necessary anymore except in the functionality that it has that vanilla promises do not. That said, closure promises I think have more consistent behaviour in older browsers

qqq07:02:09

what is wrong with the followingline: (defmulti svg->hiccup :tag) is defmulti not supported in cljs ?

Oliver George08:02:20

Should be fine

iku00088809:02:17

I am looking for a hiccup vector -> dom library, could anyone give me suggestions?

iku00088809:02:47

I have looked at Hipo, crate and hiccups so other than those.

borkdude10:02:38

I need the following behavior: get items a .. b and insert them in a data structure at indices a .. b, even if the size of this data structure is smaller than a. Maybe I can use a vector and pad with nils, or is there something better?

borkdude10:02:00

so essentially a sparse vector.

borkdude10:02:21

I think I’m better off using a JS array here

minikomi10:02:00

how about a map with indicies as keys? could keep a :indicies vector too if you like

borkdude10:02:54

Don’t know if that is performant enough, but I could try that also

minikomi10:02:27

sorted map might also be good, if keys are expected to be in order

darwin13:02:25

@borkdude I would implement a custom cljs type implementing IIndexed (and other suitable protocols) backed by a JS array, copy on write

darwin13:02:52

and maybe IEditableCollection and ITransientCollection, for more performant modifications, depends on your use-case

henriklundahl14:02:12

I have some problems with clojure-spec on the latest CLJS release. I get Uncaught Error: No protocol method ICounted.-count defined for type cljs.core/Keyword: :cljs.spec/invalid when calling cljs.spec/valid?. Anyone that recognizes this or a similar error? It seems like the keyword :cljs.spec/invalid has sneaked in among the data to be validated...

dnolen14:02:12

@henriklundahl you need to produce something minimal

tankthinks14:02:20

I didn't see it in CLJSJS; I assume either because there is a better CLJS option or it hasn't been packaged yet (maybe I can do this?)

dnolen14:02:49

@tankthinks that project looks like overkill to me unless you need all of that

dnolen14:02:56

Google Closure has basic crypto stuff

dnolen14:02:34

that lib is a 75k gzipped dep if you’re planning on using it on the frontend

tankthinks14:02:53

thanks @dnolen ... it may be overkill ... i've simply used it in the past because I trust Brock Allen and Dominic Baier who created https://github.com/IdentityServer

dnolen14:02:19

I just wouldn’t use a monolithic thing like that for the frontend

dnolen14:02:29

I would look for only the bit I need if they exist separately

dnolen14:02:53

if you’re doing Node.js stuff - then sure … doesn’t matter

tankthinks14:02:18

gotcha ... yeah ... I really just need java.util.Base64 and java.security.MessageDigest like stuff

dnolen14:02:32

yeah rule of thumb

dnolen14:02:36

just look in Google Closure first

tankthinks14:02:50

i always forget that rule 😄

tankthinks14:02:31

and you're right ... what I need is usually there, and already nice

dnolen14:02:15

and will probably contribute only a couple of kilobytes to your project 🙂

tankthinks14:02:06

it's hard to unlearn that javascript doesn't have a standard lib

tankthinks16:02:51

thanks @dnolan! ported my clj encryption code to cljs with minimal changes

tankthinks16:02:20

if goog.crypt is listening, thank you as well!

dnolen17:02:25

thinking about doing this to support D3 & jQuery singleton pattern - https://github.com/clojure/clojurescript/wiki/Singleton-Pattern-Externs-Inference-Support

dnolen17:02:29

feedback welcome

dnolen17:02:27

feedback welcome

dnolen17:02:39

these are just ideas - not promises to implement 🙂

borkdude17:02:24

I’m looking for some example of vanilla React components in ClojureScript

borkdude17:02:21

The part I’m not certain about is the use of this-as to refer to lifecycle functions

deas17:02:37

@dnolen The fruit seems so be hanging so low. Doubt I will be coming up with something really helpful. However, I just started trying to figure out how things play together in detail - compiler, closure-library, node modules and so on.

dnolen18:02:02

@jiangts I looked into CLJS-1919 far as I can tell - not a bug, you can’t do that in Clojure 1.9.0-alpha14

dnolen18:02:56

@deas the above isn’t a request for help - rather just feedback to suss out perceived issues or for people to propose better/alternative approach

deas18:02:13

@dnolen I understand. I was drilling my way through anyways. 🙂

dnolen18:02:38

now would be a good time to test master

dnolen18:02:05

planning on cutting a release around 2pm or so, it’s a bugfixes thing but want to make sure we didn’t miss something

jr18:02:57

master looking good for my project

rbertrand19:02:57

Hey everyone! Has anyone integrated https://github.com/clauderic/react-sortable-hoc into their cljs project? I have been struggling with it in my Om app. Any tips would be great. Thanks!

jiangts21:02:09

@dnolen huh, interesting. CLJS-1919 worked in the 1.9.229 release and I remember finding something online similar to what I did, so I assumed it was a valid way of using spec. I just re-googled how to use conformers and the method I just tried seems to work :thumbsup:

dnolen21:02:31

@jiangts it doesn’t work in Clojure 1.9.0-alpha14

dnolen21:02:42

it’s extremely important to actually test everything actually works in Clojure

dnolen21:02:50

we just copy the implementation over and details change

jiangts21:02:17

gotcha. I must’ve found something online that relied on implementation specifics of 1.9.229 or something

jiangts21:02:27

it works now that I’ve found the correct way of using it 🙂

dnolen21:02:47

right there may have been other problems too

timgilbert21:02:37

I'm also 👍 on the ^:singleton metadata idea, and am waging a furious internal battle to resist bike-shedding the name of the keyword

dnolen21:02:27

@timgilbert now’s good time to suggest alternatives

dnolen21:02:39

it’s not something I feel strongly about as it’s not something I ever personally intend to use 🙂

timgilbert21:02:28

Well, I wonder whether it would make sense to use a namespaced keyword, :js/singleton or something

dnolen21:02:46

sounds great to me

dnolen21:02:40

updated the wiki

dnolen21:02:10

I won’t get to any soon then the next release so there’s no rush to find a better name

timgilbert21:02:35

Awesome! I looked over the other proposal but I don't have strong feelings about (other than some sympathy towards you for needing to interface with existing JS build systems). In the past when I've needed to call out to npm I used https://github.com/RyanMcG/lein-npm but I don't need to do so often.

dnolen21:02:30

@timgilbert we’re just going to shell out to Node.js here - it needs to work apart from Leiningen or any other additional tooling

timgilbert21:02:09

Right, that makes sense

timgilbert21:02:29

Pardon my ignorance, but is the bit about dependency conflicts there because in a cljs environment, each transitive dependency would wind up in its own top-level Clojure namespace? Like, if the dependency tree is {:a {:x "1.23" :y "1.0"} :x {:y "2.0"}}, when we (require [y]) we need to know whether to pull in 1.0 or 2.0?

timgilbert21:02:39

(not sure if that dependency tree makes sense, but just conflicting transitive versions in the tree is what I was going for)

mfikes21:02:34

You can now install Planck on Ubuntu 14.04 and 16.04 using apt-get:

sudo add-apt-repository ppa:mfikes/planck
sudo apt-get update
sudo apt-get install planck
Give it a spin; let me know if you see any issues.

dnolen21:02:04

@timgilbert it doesn’t really have anything to do with that

dnolen21:02:56

and everything to do with the fact that we use maven but we’ll have deps from some other system as well - and these two systems can’t interact

dnolen21:02:56

but yes that’s the problem

dnolen22:02:21

we don’t care about clashes of transitive deps within Node.js

dnolen22:02:36

just clashes between direct deps referenced from our own dep graph

timgilbert22:02:37

Ah, I see. So is the concern conflict between deps pulled in by, say a leiningen cljsjs package and an npm one?

dnolen22:02:50

between CLJS libraries

dnolen22:02:09

CLJS lib A uses React 15, CLJS lib B uses React 16

dnolen22:02:20

before and beyond that we don’t care

dnolen22:02:31

it’s right where the two dependency systems meet that’s the issue

timgilbert22:02:59

I think I see, thanks. So these are the sort of things you'd use like a lein [lib.foo "1.2" :exclusions [transitive.lib]] dependency to resolve in JVM Clojure?

dnolen22:02:10

except I don’t want to replicate all that

dnolen22:02:21

just always warn when there’s a conflict

dnolen22:02:37

and you have to provide a decision in your :npm-deps

timgilbert22:02:53

Got it. Thanks for the explanation

assoc-in22:02:40

@dnolen I am hoping that I can use the same specs for both the front and backend. I am guessing that I would place them in a cljc file, but I was wondering how the s/def would work with s referring to clojure.spec and cljs.spec. Any ideas? I asked in the spec channel and Alex Miller mentioned that the new auto alias function may let me just have my specs in a namespace in cljc and then refer to it from both clojure and clojuresciprt, but he recommended asking you. Thanks!

dnolen22:02:22

just always write clojure.spec

dnolen22:02:36

like (:require [clojure.spec :as s])

dnolen22:02:06

the only time you have to be careful is :cljs.spec/invalid not :clojure.spec/invalid

dnolen22:02:12

but you can avoid even that with ::s/invalid

assoc-in22:02:28

@dnolen Okay awesome that will make writing specs for both a lot eaiser

victorvoid22:02:13

Hi guys! I'm using cljs-ajax but when I do GET requisition, is very well, and is saving data in my app-db (I'm using re-frame) but I can not get a map key of the response:

victorvoid22:02:22

I need to get the items

victorvoid22:02:08

but when I do (.log js/console (:items response)) return 'null'

darwin23:02:40

@victorvoid don’t you need :keywordize-keys when calling js->clj? otherwise you have to use string keys

darwin23:02:02

in general it is not considered a good practice to use js->clj to transform “unknown” data 1) if it is too big, it will lead to performance issues 2) if it contains some wild stuff, it will throw better leave it in js land and cherry-pick only stuff you really need and know its shape

victorvoid23:02:12

Nice, thanks! But how I get :items ?

darwin23:02:15

(aget response “items”) maybe? or (aget response “items ”)? it is not obvious to me from your code snippet

darwin23:02:37

what about logging whole response and then figuring it out from its shape?

darwin23:02:17

(.log js/console response) there and see what it gives you back

victorvoid23:02:00

using (aget ...) return 'undefined'

darwin23:02:39

ok, it is a clojurescript map, (.log js/console (get response “items”)) will do the job