This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-06-30
Channels
- # admin-announcements (3)
- # aws-lambda (12)
- # beginners (88)
- # boot (73)
- # capetown (6)
- # carry (16)
- # cider (8)
- # cljsjs (7)
- # clojure (90)
- # clojure-belgium (4)
- # clojure-dev (19)
- # clojure-greece (41)
- # clojure-portugal (1)
- # clojure-quebec (4)
- # clojure-russia (25)
- # clojure-spec (172)
- # clojure-taiwan (1)
- # clojure-uk (76)
- # clojurescript (82)
- # cursive (37)
- # datavis (2)
- # datomic (46)
- # devcards (1)
- # emacs (4)
- # euroclojure (6)
- # events (1)
- # hoplon (31)
- # jobs (1)
- # keechma (9)
- # off-topic (4)
- # om (7)
- # onyx (65)
- # other-languages (15)
- # pedestal (1)
- # planck (50)
- # proton (1)
- # re-frame (40)
- # reagent (7)
- # spacemacs (14)
- # spirituality-ethics (37)
- # testing (1)
- # untangled (2)
- # yada (44)
@venantius: i think you can specify :es6
as an option for :module-type
for a foreign-lib. I haven’t personally used it. So can’t vouch for it. https://github.com/clojure/clojurescript/wiki/Compiler-Options#foreign-libs
Anyone aware of a library that let's you describe a set of derived atoms
based on one atom (ideally allowing dependencies between the derived atoms)?
@martinklepsch: something like rum
's derived-atom
(https://github.com/tonsky/rum#091)?
the similar stuff off the top of my head: Javelin, freactive.core, reagent (reactions/ratoms) and maybe frozenlock/entanglement
and also funcool/lentes
@metametadata: these are all fine to get a new atom based on one or more other atoms but I want to construct many of these derived atoms based on some description. Maybe combining derived-atom
+ component
will allow me to achieve that
Hi, whats the best way to go from a JSON object to a native Clojurescript Hashmap?
@crankyadmin: There's js->clj
.
(GET "/accounts/user-stats"
{:handler #(do (println "results: " (js->clj % :keywordize-keys true) )
(reset! user-stats (js->clj % true)))
:format :json
:response-format :json})
{"username":"crankyadmin"}
<--- that the server returns.
js->clj
appears to returning a vector.
I'd really like it to look like {:username "crankyadmin"}
If a reference to an atom is "lost" i.e. it can be GC'ed does this also remove watches?
any recommendation for a game engine for game like mario in clojurescript? So far I found https://github.com/alexkehayias/chocolatier which looks promising
I equally don't understand why its trying to turn {"username":"crankyadmin"}
into a array...
@martinklepsch yeah, atom should be gc'ed with all its fields. I guess I even tested it some time ago with devtools in browser 🙂
@metametadata: thanks!
In CLJS apps we often have derived atoms/reactions/`track` etc. Most of the times we just def. these things but I thought maybe it's nice to represent this as a dependency graph which allows construction of these interrelated references without globals, came up with this: https://gist.github.com/martinklepsch/c5a2feacc63ce08565fcffe37951ab64 — any feedback/thoughts welcome! /cc @metametadata
Hi! Has anyone ever encountered this error:
user-error: `cider-load-buffer' needs a ClojureScript REPL.
If you don't know what that means, you probably need to jack-in (`C-c M-J').
It appears when I regularly open a .cljs file and try to compile it with C-c C-k.@martinklepsch: looks neat! do you plan using this in Reagent apps somehow?
Also, every clojurescript file ever starts in clojure major mode, instead of the clojurescript one. Do somebody know why?
@metametadata: Considering it for a Rum app for now but could be used in Reagent as well. Drawback to something like re-frame's subscribe is that the deriving is always done no matter if a component actually uses the derived data
Yeah, good point. I also think reagent component won't be able subscribe to a plain atom, it needs ratoms/reactions.
@metametadata: right but that's a matter of swapping rum/derived-atom
with reaction
or track
Hi, I could not find explanation in clojurescript wiki for above, so was wondering if somebody from this # could help me.
for Google Closure libraries does :import
only work for things that have been provide()
-ed?
i’m working with goog.ui.KeyboardShortcutHandler
, it provides goog.ui.KeyboardShortcutHandler.EventType
enum & I can :import
that, but it also has goog.ui.KeyboardShortcutHandler.Modifiers
that it doesn’t provide (but example JS code clearly accesses)
attempting to :import goog.ui.KeyboardShortcutHandler.Modifiers
results in an error
I am able to do:
(ns example.core
(:import [goog.ui KeyboardShortcutHandler]))
(println KeyboardShortcutHandler.Modifiers)
@rorydouglas: what you say does seem true though.
thanks @rohit
yeah it seems i can access them, just can’t access them the same way i do from imported Enums (e.g.. can’t do Modifiers.CTRL)
@rorydouglas: seems that way. you could raise an issue with closure-library. imho, it should have been provided
here as you observed: https://github.com/google/closure-library/blob/master/closure/goog/ui/keyboardshortcuthandler.js#L22
will do - thanks!
Hello All 🙂
Would someone be able to help guide me through the following function? I've been using ClojureScript for a few days now, but can't seem to get my head around the bit-or
method being used?
(defn get-uuid []
(apply
str
(map
(fn [x]
(if (= x \0)
(.toString (bit-or (* 2 (.random js/Math)) 2))
x))
"00000000-0000-4000-0000-000000000000")))
I understand that x
is being used to generate a .random
int
that is being multiplied by 2
using the js/Math
library.
It is then converted to a string
. I also understand that the map
may be applying the randomly generated int
s to the string 00000000-0000-4000-0000-000000000000
…
However, are there any simpler alternatives to doing something similar without the bit-or
? I assume the bit-or
are key here. Sorry for the newbie question.@kino https://github.com/clojure/clojurescript/blob/a5cb207d30c9343a850d6364df674b838fb9c9ba/src/main/cljs/cljs/core.cljs#L10231
It is unclear what you are asking..how the code works or how to get a uuid? You are mapping the inner fn over the "0000..." and swapping out the zero characters with your bit-or result.
@ojd look up bitwise-or somewhere, hints you have an random number and you are trying to pull a hexadecimal value (0-F) out of that random number
Yeah, not sure what’s going on with that code, the (.toString (bit-or (* 2 (.random js/Math)) 2))
seems to be generating random 2’s and 3’s only.
Can goog-define be used with advanced compilation? Docs say not so with whitespace, but don’t mention advanced
@manutter51: Most likely, JS bit-wise or operator is coercing the arguments to unsigned integers, basically looking like:
(2 * Math.random()) >>> 0
which bounces around between 1
and 0
. If you or that with 2
, you'll just get your 2
and 3
resultOr at least, it's converting it to a signed int: see here: http://www.ecma-international.org/ecma-262/5.1/#sec-11.10
@bhauman @manutter51 @wildermuthn thanks guys. I was unsure when I saw it as well. Will try researching @peterschwarz alternative as well.
@pat thank you Pat. Yes, I was just trying to figure what the code was trying to do and any alternatives that make sense.
@kino: you should of course use the one in cljs.core https://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/core.cljs#L10231
Anyone have an example repo where you use your custom javascript in your cljs app? Like.. https://github.com/clojure/clojurescript/wiki/Dependencies#user-content-google-closure-compiler-compatible-code I’m using reagent / figwheel and following those directions. Created a build.clj as suggested, compiled my app, but nothing happens, output isn’t generated.
The app works, but once I add this into my project.clj, it doesn’t
:compiler {:main reagent-closure-compatible-js.core
:libs [{:file "yayquery.js" :provides ["yq"]}]}
:output-to "resources/public/js/compiled/app.js"
:output-dir "resources/public/js/compiled/out"
:asset-path "js/compiled/out"
:source-map-timestamp true}}
here’s the repo btw https://github.com/hzhu/reagent-closure-compatible-js
Hmm now it throws an exception when I run lein figwheel dev
. I added this to project.clj https://github.com/hzhu/reagent-closure-compatible-js/blob/master/project.clj#L29
Exception is pretty unintelligible
clojure.lang.ExceptionInfo: Error in component :figwheel-system in system com.stuartsierra.component.SystemMap calling #'com.stuartsierra.component/start {:reason :com.stuartsierra.component/component-function-threw-exception, :function #'com.stuartsierra.component/start, :system-key :figwheel-system, :component #figwheel_sidecar.system.FigwheelSystem{:system #object[clojure.lang.Atom 0x2835de0c {:status :ready, :val #<SystemMap>}]}, :system #<SystemMap>}