This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-05-09
Channels
- # admin-announcements (6)
- # arachne (3)
- # beginners (66)
- # boot (84)
- # braveandtrue (1)
- # cider (84)
- # cljs-site (1)
- # cljsjs (3)
- # cljsrn (2)
- # clojure (138)
- # clojure-austin (2)
- # clojure-czech (1)
- # clojure-gamedev (6)
- # clojure-germany (15)
- # clojure-italy (2)
- # clojure-russia (26)
- # clojure-uk (51)
- # clojurescript (97)
- # css (1)
- # cursive (1)
- # datascript (13)
- # datomic (6)
- # devcards (2)
- # docker (1)
- # emacs (5)
- # hoplon (9)
- # immutant (5)
- # jobs (4)
- # leiningen (6)
- # luminus (27)
- # mount (4)
- # om (16)
- # om-next (4)
- # onyx (15)
- # other-languages (36)
- # overtone (1)
- # proton (3)
- # quil (1)
- # re-frame (11)
- # reagent (24)
- # rum (4)
- # spacemacs (3)
@abdullahibra: "links and images have the same id" -> Elements should never share IDs. The way you have phrased your question its hard to help you. Could explain what you are trying to accomplish a little clearer? Perhaps even showing the code you have as an embedded "snippet" instead so we can read it better.
Hey, so I'm implementing an ECDSA signature system in clojurescript, and I want to use the window.crypto object
Any ideas on how I can go about doing this? I can just use Math.random() but it's really insecure.
Thanks @ivanreese that's great feedback
note to self: if you start getting baffling errors about str.call
is not a function, check you didn’t stupidly (let [str …])
above
hi guys
i'm trying to make an event for when clicking link i got src of img inside the link, my code http://www.refheap.com/118860
can anybody help please in this?
@abdullahibra: I guess the problem is in (js/$ this)
try (-> event .-currentTarget js/$)
instead, even better find a way of doing this with google closure library instead of jQuery
alun: it's working now but i still only get working for the first link image, and i get no effect for the other link images, the current code is: http://refheap.com/118865
@dnolen: What's the status of core.typed
for clojurescript? Are/will there be any efforts to get it working again?
Yeah I figured. It would be a nice to have since I'm kind of stuck with Node on the backend
I tried the Clojure compiler type checking on the wiki (Compile-Time-Type-Checking) also, but it's giving really noisy errors from the closure compiler and clojurescript libs that I want to ignore.
@risto yes that stuff is not fully baked - still needs a lot of work - and ultimately it can only do limited kinds of checking
Can I do something like ???
:on-click (fn [e]
(go (let [[x] (<! (chan-returning function))]
(println x))
@urbanslug: yes I believe so. Or, since go blocks have some (small) cost, you could consider core.async's take!
: (fn [e] (take! (chan-returning function) println))
can anyone tell me how can I add npm dependencies in clj.boot project. for lein there’s lein-npm plugin, I’m thinking about switching to boot.
@ag that might be a good question for #C053K90BR
Is there a more idiomatic way to express something like:
(cond
(number? x) …
(string? x) …
(sequential? x) …
(associative? x) …
:else …)
It doesn’t seem like something I can extract into multimethods, but if there is a way, I’d love to learn it. 😄(I asked here instead of #C03S1KBA2 because I’m not sure if the way for doing this differs between Clojure and ClojureScript, and I’m coding with the latter.)
@borkdude: I’ve been thinking of that too, I’m just a little lost on the details of how to achieve it.
@cky: multimethods seem more natural to me if you have only one function for each type
Right, I’d like to be able to use either multimethods or protocols. I guess the question is how to make it so that all sequential?
types get dispatched one way, all associative?
types another, etc.
@cky: if each of your cond predicates can be reduced to a type-check, then extending a protocol seems like a natural fit
I’m not convinced that the cond is so bad in and of itself, depending on the context
@ddellacosta: Right, I was wondering how you might write the extend
so that it matches all sequential?
types or all associative?
types, etc. I guess you’re right in the latter statement that cond
might be the way to go.
cky:
(extend-protocol Help
java.lang.String
(try-me
([] "string implementation")
([x y] (str "Hello" x "and" y)))
java.lang.Object
(try-me
([] "Object implementation")
([x y] (str "Hello" x "and" y))))
6ewis cky yeah but that’s not going to work for sequential?
and associative?
which are themselves checking whether the type itself satisfies a given protocol. For example: https://github.com/clojure/clojurescript/blob/dd589037f242b4eaace113ffa28ab7b3791caf47/src/main/cljs/cljs/core.cljs#L1978-L1980
Right, what @ddellacosta said.
I’m honestly not sure how you’d do this meaningfully with a multimethod either…
again, there is some missing context here that makes it hard to suggest an alternative to the cond
the predicates are testing something that seems like it could be any of a number of types
(defmulti example class)
(defmethod example java.lang.String [input]
(str "String -" input))
(defmethod example java.lang.Long [input]
(str "Number - " input))
The context here is I'm trying to reimplement cljsjs/classnames
in native CLJS so that 0 is treated as truthy.
6ewis: again, how do you test the values which are being checked for satisfying a protocol with the multi-method? class
doesn’t suffice here
@ddellacosta: Exactly.
@ddellacosta: can't we do something along those lines:
(defmulti example input )
(defmethod example (fn [arg] (associative? arg)) [input]
(str "associative -" input))
I see the path you’re going down, but even if it were possible, the question you then have to ask yourself is: why bother using a multi-method?
at a certain point it’s far more obvious what is going on with the cond
I should probably head back to my work. I'm not being helpful , just adding more fuel to the fire 😉
@lewix: I don’t know much about the performance characteristics of protocols, but the conventional knowledge is that multi-methods are slower for doing something like type dispatch
when the two are compared in that sense
@lewix heh…it’s fun to try to figure this stuff out though, I get it 😄
@ddellacosta: thanks for your input
@lewix: np. FWIW, here’s a great piece by @alexmiller, exactly on point: http://insideclojure.org/2015/04/27/poly-perf/
also @cky take a look ^
although, I suppose that’s Clojure vs. CLJS so maybe the performance measurements will not be relevant, but the rule of thumb guidelines in the beginning are useful
per your question above 6ewis, he says > Protocols maximally leverage the type-based dispatch built into the JVM.
so, there’s that
I'm having an issue with reagent where after I refresh a div full of components, after performing a search, the first result of the list is rendered as the first result of the first search performed, always
It's not a data issue as I've checked that, so I suppose somewhere there's an issue in the DOM but I can't quite pinpoint it
Is in clojurescript core something like lodash’s _.toPlainObject
?
https://lodash.com/docs#toPlainObject
@ddellacosta: Thanks for the link! I'll check it out when I get home, and true, I think there're cases where cond
is indeed the best choice. I was trying to get a feel for whether this is one of those situations, or whether I was missing an obvious technique. Thanks for your input!
@cky you’re welcome, and thanks for asking—I learned something too investigating the question!
I got feedback from 2 others in my local dev group who also feel that cond
is the best approach in this instance. Yay for data points. ☺️
there ya go 😉
Is anyone aware of a Selmer style template library for ClojureScript? I don’t need the full complexity of Selmer (template files and so on) but I have string creation needs that make str
a little cumbersome.
Hello, I'm fairly new to clojure learning by the book Clojure for the Brave and True. But I'm seeing some barrier between that content and the sheer ammount of react's facade out there for clojure. I'm a former React/Redux programmer. Any way to get started in how to plan a react with optional server rendering and god help me something besides rest, like graphql?
Thanks for the awesome job guys
@vinnyataide: rum
supports server-side rendering.
https://github.com/tonsky/rum
thanks
what is datascript and how it relates to transit?
don't know about "plan" part, but usually you'll have some pocket with app state (atom, datascript db, etc.), and your components will: 1. react to its changes. 2. update it. how exactly will you init/keep that state in sync with back-end - is up to you. could be REST, could be single "smart" endpoint
datascript is a front-end (and now a back-end too) "clone" of Datomic data base. with datalog as query language and cool "pull" feature.
Transit is a format and set of libraries for conveying values between applications written in different programming languages.
read "json on steroids"
basically data serialization format w/o type-information loss*. (* terms and conditions may apply)
awesome
hahahaha
gonna search about this cool pull feature
I'm seeing the datomic architecture
seems hard to believe it works
every app as a brain
@vinnyataide: Yeah it's definitely an interesting idea. I think it uses caching heavily. I haven't explored it very much yet, but I'm wondering if it's using websockets to inform clients of db updates