This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-10-17
Channels
- # beginners (45)
- # boot (33)
- # chestnut (9)
- # cider (2)
- # cljs-dev (24)
- # cljsrn (1)
- # clojure (114)
- # clojure-conj (3)
- # clojure-dev (3)
- # clojure-dusseldorf (3)
- # clojure-greece (5)
- # clojure-italy (22)
- # clojure-russia (10)
- # clojure-spec (12)
- # clojure-uk (19)
- # clojurescript (117)
- # core-async (16)
- # cursive (3)
- # data-science (1)
- # datomic (5)
- # docs (13)
- # emacs (1)
- # fulcro (13)
- # graphql (1)
- # hoplon (20)
- # immutant (3)
- # jobs (1)
- # juxt (12)
- # lein-figwheel (1)
- # luminus (4)
- # off-topic (12)
- # onyx (61)
- # portkey (1)
- # re-frame (21)
- # reagent (26)
- # ring-swagger (38)
- # rum (1)
- # shadow-cljs (222)
- # slack-help (4)
- # spacemacs (11)
- # specter (67)
- # uncomplicate (236)
I’m wondering how I can make an external library initialize when it provides no externs: https://github.com/cljsjs/packages/tree/master/smoothscroll-polyfill https://github.com/iamdustan/smoothscroll
ah, it is getting called
unfortunately, it believes the browser which I’d prefer to override.
hey how can we convert this into cljs $(window).load(function() { $(this).joyride(); }) and i tried it like this :component-did-mount #(.load (jq/$ "window") (fn [] (.joyride (jq/$ "#first")))) but it's not working. can any one tell whats the right way?
i didn't know how to use this in the cljs so can i use (.joyride (jq/$ "this"))? @thheller
so now
(.load (jq/$ js/window) (fn []
(.joyride (this-as x (jq/$ x)))))
is this right? @thhellerhmm.. Just testing at the REPL I can see that you can manually order a map I can also see that select-keys keeps the order, so I’m not sure why it doesn’t happen for my use-case
clojure has 2 map types, array-map and hash-map. array-map is ordered but becomes hash-map at a certain threshold
added a little note: http://clojuredocs.org/clojure.core/select-keys#footer
@metametadata Do you mind if I ask a few questions regarding Etaoin setup?
when using cljsbuild
, how can I define a default
profile? Or do I need to always specify lein cljsbuild once <whatever>
?
Hey we noticed random-uuid is using Math/random via rand-int, would it be better to use js/window.crypto.getRandomValues to get cryptographically strong pseudo random numbers for UUIDs or is Math/random used intentionally because it is sufficient?
ideally we don’t do this ourselves, but rely on Google Closure to chose the right thing
but generally, Math.random is bad for security applications: https://blog.securityevaluators.com/hacking-the-javascript-lottery-80cc437e3b7f
Hey guys I want to use goog.date.UtcDateTime
but I don't know how to import it and call it, can someone help me?
if it’s a class, import with (:import goog.date.UtcDateTime)
then refer to it directly, create an instance for example (goog.date.UtcDateTime.)
I used (:import [goog.date UtcDateTime])
so to call methods on objects of this class I do (.toUTCIsoString d)
?
The problem I'm trying to solve is that on server I have UTC timestamps and on client I have local times. I'm looking for a way to convert from/to and I can't find it in google closure library
I’m having a really weird problem… I depend on an npm module jwt-decode. When I’m using figwheel and do a lein clean
and then a lein figwheel
everything is fine. But if I refresh the page, I get the not-found error (
Undefined nameToPath for module$Users$tbowers$code$quorum$manager$node_modules$jwt_decode$lib$index
). If I lein clean and lein figwheel again everything is fine. Also, in general - hot reload works too… so it’s only when I actually click refreshIf I need a conditional require for nodejs in cljs/core.cljs, is there a place to put it, like a preamble that's only loaded for node? Alternatively I could do it based on target Do we even want a nodejs-require for crypto in ClojureScript?
@roklenarcic one of the solutions is to use Unix Epoch milliseconds when communicating between frontend and backend. Look at goog.date.DateTime.fromTimestamp
or an even simpler (js/Date. epoch-millis)
.
hi, I have a component [comp]
instantiated inside a component X
. Based on some change in component X
I want [comp]
to be re instantiated (so it executes its did-mount function, and not only render). Is there some way to do it without moving the local state of comp
to X
?
@tomaas , don't do that
better to register a component-did-update lifecycle method as well as component-did-mount
a nice pattern is to define a smart "inner" component that receives the relevant values as props
then you can use something like this: https://github.com/pesterhazy/recalcitrant#buidling-components-with-lifecyle-methods
@abp - I was wondering the same thing and I ended up with different builds for frontend/backend that just didn’t include node files. If you need it in the same ns I suggest using target
alternatively, specifically for crypto, you could use one of the shims that does the right thing in both situations and then you’d just be using the regular (:require
@tobowers Thanks, but I'm working on ClojureScripts core.cljs to improve the random-uuid function, so I'm writing a shim there for the patch, on node it seems to be a bit more challenging
Hello all, what is a good starter kit these days for building a Full-Stack SPA using WebSockets and re-frame for the front end? Thanks!
I've received a suggestion in #re-frame to use https://github.com/Day8/re-frame-template
what is the meaning of #js that I see everywhere?
I'm pretty new to clojure and clojurescript
It creates js object or array literal
or the equally wonderful https://cljs.github.io/api/
ClojureScript's "missing manual"
Hi all, (keyword :foo :bar)
works in cljs, but throws in clj. I’ve checked the source and it seems intentional on the cljs side, and has been this way for 4 years. Does anyone know why this is so?
edit: should be arity 2, not 1
there are a lot of things in cljs and clj that work accidentally but aren’t intended features, especially in regards to creating valid keywords and symbols
that said, I don’t know if the discrepancy is an accidental feature of cljs or just an intentional difference between the languages
Or a bug
well - it’s definitely not a clj bug, I guess you could arguably call any unintentional feature a bug
not a clj bug
maybe cljs bug, maybe cljs feature, maybe “unintentional feature” ?
it seems to be an intended feature in cljs because there is a cond
clause specifically testing for keyword?
so it’s definitely intentional
good to know
which makes me wonder if it’s a planned feature for clojure, and they just haven’t gotten around to implementing it.
I’d suspect not a planned feature - it would be easy to implement
wait - it doesn’t throw in my clj? did you have the cases backward?
user=> (keyword :foo)
:foo
user=> *clojure-version*
{:major 1, :minor 8, :incremental 0, :qualifier nil}
Oh sorry, it should be arity 2
(keyword :foo :bar)
oh, OK - that makes more sense, thanks
and given that case, I do wonder whether they intend for parity or if it’s a difference in api…
(defn keyword
"Returns a Keyword with the given namespace and name. Do not use :
in the keyword strings, it will be added automatically."
{:tag clojure.lang.Keyword
:added "1.0"
:static true}
([name] (cond (keyword? name) name
(symbol? name) (clojure.lang.Keyword/intern ^clojure.lang.Symbol name)
(string? name) (clojure.lang.Keyword/intern ^String name)))
([ns name] (clojure.lang.Keyword/intern ns name)))
are you sure that's not a bug in clj? There's a lot of care in the first arity that is just ignored in the two arity version
I am but a mere peasant. How could I presume it’s a bug in CLJ? 😛
well i don't know where to find a specification of what it /should/ be so i suppose that the implementation is the reference
I would tend towards considering this as CLJ being under permissive though.
i'm just going on the fact that there is some consideration of different types in the 1 arity branch which they explicitly ignore in the second. but i suppose you need to see what /intern looks like
how about (fn ([x] (keyword x)) ([x y] (keyword (name x) (name y)))
as a portable version - any gotchas there?
well if you passed a string, it would throw.
nope!
user=> (name "foo")
"foo"
oh it works
user> (keyword :hi)
:hi
user> (keyword "user" "hi")
:user/hi
user> (keyword "user" :hi)
ClassCastException clojure.lang.Keyword cannot be cast to java.lang.String clojure.core/keyword (core.clj:595)
name is the great equalizer between str / kw / sym
well - as long as namespaces are out of scope (as they should be with two args anyway)
(name :foo/bar) - “bar”
that’s where it’s lossy - but with two arg keyword call you don’t care about that case - it is nonsense in that instance
thanks for the answers here 😛
anyway, thanks for the thoughts, @dpsutton and @noisesmith! I will retire to bed now
is there any point to using something like https://github.com/funcool/struct over core.spec
?
I find struct is really nice in route handlers, for validating form input and providing nice error messages to users.
i was considering using it for client side form validation, but our server already has a ton of core.spec code, an i'm wondering if it makes more sense to try to repurpose the spec code
hm from my cursory looking at the optinos, seems like struct has the best semantics for doing frontend validation
Hey Guys, I’ve open sourced Clojurecademy 🎉🎉🎉 https://github.com/clojurecademy/clojurecademy