This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-12-13
Channels
- # bangalore-clj (5)
- # beginners (94)
- # boot (145)
- # cljs-dev (4)
- # cljsjs (79)
- # cljsrn (18)
- # clojure (343)
- # clojure-dev (21)
- # clojure-dusseldorf (6)
- # clojure-india (1)
- # clojure-italy (2)
- # clojure-nl (4)
- # clojure-russia (62)
- # clojure-sanfrancisco (1)
- # clojure-spec (109)
- # clojure-taiwan (1)
- # clojure-uk (103)
- # clojurescript (102)
- # code-reviews (30)
- # component (1)
- # cursive (39)
- # datascript (7)
- # datomic (68)
- # emacs (11)
- # figwheel (1)
- # gorilla (1)
- # hoplon (234)
- # off-topic (46)
- # om (52)
- # onyx (32)
- # planck (9)
- # proton (4)
- # protorepl (5)
- # random (1)
- # re-frame (36)
- # ring (18)
- # ring-swagger (1)
- # specter (6)
- # untangled (3)
- # vim (56)
ok, so i got this far https://github.com/cljsjs/packages/blob/a486e6af0389a1d2754e3a21e7772f082b208815/react-virtualized/build.boot#L23-L36
probably easier than reimplementing the algorithm, although i am not quite sure, that formula doesn't look this complicated š
what is the best way in clojurescript to extend ES6 classes? I want to extend code like in this example: https://github.com/substance/simple-writer/blob/develop/lib/simple-writer/SimpleWriter.js#L9
@podviaznikov not sure if there is a better way but I just do it manually ā¦ stole it from one of the many react libraries (probably om ;p)
(defn ^{:jsdoc ["@constructor"]} Root []
(this-as this
(.apply js/React.Component this (js-arguments))
this))
(set! (.-prototype Root)
(goog.object/clone js/React.Component.prototype))
(specify! (.-prototype Root) Object ā¦ your stuff ā¦)
thank you @hueyp!
I tried to cache canvas data by caching the dataURL. Turns out redrawing the canvas is like 50x faster than creating an image from the dataURL. Does that make sense?
but it also depends on a bunch of factors, however i expect canvas to be extremely fast by itself
it depends on the amount of operations on the canvas vs the amount of data generated by the canvas I guess
my first guesses for why the dataURL method might be slower are 1. conversion might be hard 2. some DOM API might be touched and that obviously ruins everything immediately
Is there already a macro that wraps (js/performance.now) around the body and prints the duration of an expression that I donāt know of maybe? š
(defmacro profile-always
"Stays in production"
[k & body]
`(let [k# ~k
t0# (js/performance.now)]
(let [res# (do ~@body)
t1# (js/performance.now)
ms# (- t1# t0#)
report# (str k# " " ms# "ms")]
(if (< 10 ms#)
(js/console.warn report#)
(js/console.info report#))
res#)))
there is cljs.core/system-time
, btw
@borkdude we have support for :reload
at the REPL, downstream tooling can easily support macro-redef
Made this one now:
(defmacro profile-js [k & body]
`(do
(defonce ~'profile-stats (atom {}))
(let [k# ~k
t0# (js/performance.now)
res# (do ~@body)
t1# (js/performance.now)
ms# (- t1# t0#)
all-stats# (swap! ~'profile-stats
update k# conj ms#)
k-stats# (get all-stats# k#)
avg# (/ (apply + k-stats#)
(count k-stats#))
report# (str k# " " ms#
"ms, average: " avg# "ms")]
(js/console.info report#)
res#)))
(credits to @rauh for the idea)example output: https://www.dropbox.com/s/chp01s6df6jvax3/Screenshot%202016-12-13%2013.46.06.png?dl=0
@dnolen About yesterdays conversation: This also means we should avoid declare
for performance critical code since the cljs compiler won't know the exact arity of the function and generate unoptimal code. Good to keep an eye out.
Hi
import createRichButtonsPlugin from 'draft-js-richbuttons-plugin';
const richButtonsPlugin = createRichButtonsPlugin();
Given that, what would the clojurescript version be?
(defn createRichButtonsPlugin (aget js/window ācreateRichButtonsPluginā))
Trying to use, https://github.com/jasonphillips/draft-js-richbuttons-plugin#usage
(def createRichButtonsPlugin (. js/window -createRichButtonsPlugin))
@anmonteiro you the man!
aget
is meant to only be used for arrays
Iām ashamedā¦ I knew that.
Its been a head bashing off desk morning.
that wasn't the problem with the above though. It would work (currently), but that's an internal implementation detail
your problem was the defn
I get a esModule back now. Which is a step forward. š My main problem is that Iām having difficulty porting this https://github.com/jasonphillips/draft-js-richbuttons-plugin#usage to cljs
I just want the CodeButton
object
@crankyadmin hrm there should be a default
key in the object you get, probably
so
(def createRichButtonsPlugin (.. js/window -createRichButtonsPlugin -default))
^ maybe
(def richButtonsPlugin ((.. js/window -createRichButtonsPlugin -default)))
(def CodeButton (aget richButtonsPlugin āCodeButtonā))
Got me what I needed š Thanks for the help!@rauh we always generate arity check + dispatch if we canāt figure it out - but yes declare
is like the higher order case
How can I clone and install the google-closure-library local? I found a bug and wan't to resolve it for my project.
@danielgrosse afaik @stuartsierra is packaging that for Maven etc, maybe he has some advice or repo up somewhere
in the clojurescript repo there is a script under /script/closure-library-release
thatās the script used to build the lib that clojurescript depends on so you could modify that
@alexmiller Thank you. I will look into it.
Hi, why the (for ...) clause in the let
clause did not run? I logged the value of k and v but it shows nothing.
@danielgrosse you can also just put the file you want to edit into your source path
I'm trying to use a js package in my cljs app, the js package add the object A to window. How can i require the A object using cljs ?
it has a global object which contains several react components. What is the best practice to use the children of the Grommet object ?
@dnolen since intern
in not implemented in cljs, how can i define a var from a string ? something like (intern ns (symbol "x") value)
reified vars and namespaces are pretty much incompatible with the advanced compilation model
@lxsameer we can simulate only the static aspect of vars, like dump the metadata for a var - but all the dynamic stuff is not possible
the trigger seems to be that the second form's :max-count is higher than the first ones
@enajski I donāt see anything obvious, I would use source maps and use a debugger to see where itās failing in cljs.spec/coll-prob
newbie clojurescript questions here. I am using material-UI from cljsjs in my project. How do i use it? For example, how would i use the App Bar component http://www.material-ui.com/#/components/app-bar
@dnolen what environment information would be useful? I'm connected to a figwheel/cljs-repl and evaling the code
in anycase I would look at the source for coll-prob
I donāt see how you could get that error
yup, it's really not obvious why this happens as the clj implementation looks very much alike and no errors occur
so the stacktrace I posted was from Chrome, trying the same in Firefox yields a different message:
in Safari: #object[TypeError TypeError: undefined is not an object (evaluating 'cljs.core.unquote.call')]
take note of the version that gets installed into your local Maven, and use that in your project instead
I can't seem to find a function for finding the floor, ceiling and raising a number to an exponent, do people just use js/Math?
theres a goog.math.safeFloor and goog.math.log10Floor and goog.math.safeCeilā¦ https://github.com/google/closure-library/blob/master/closure/goog/math/math.js