This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-05-05
Channels
- # aws-lambda (1)
- # beginners (294)
- # boot (35)
- # cider (19)
- # cljs-dev (39)
- # cljsrn (7)
- # clojars (48)
- # clojure (266)
- # clojure-android (1)
- # clojure-brasil (1)
- # clojure-france (2)
- # clojure-greece (5)
- # clojure-italy (7)
- # clojure-mexico (1)
- # clojure-russia (24)
- # clojure-spec (10)
- # clojure-uk (31)
- # clojurescript (134)
- # consulting (7)
- # cursive (69)
- # datomic (20)
- # emacs (57)
- # events (2)
- # figwheel (2)
- # hoplon (1)
- # jobs-discuss (19)
- # luminus (33)
- # lumo (18)
- # mount (1)
- # off-topic (32)
- # om (5)
- # onyx (27)
- # pedestal (15)
- # re-frame (12)
- # reagent (28)
- # rum (2)
- # schema (2)
- # spacemacs (9)
- # unrepl (2)
- # untangled (7)
- # vim (5)
- # yada (4)
How do you call the "superclass" method of a JS prototype-based inheritance object from Clojurescript? The call I'm trying to make would correspond to: Phaser.Particle.prototype.update.call(this);
and I did: (this-as this (.call js/Phaser.Particle.prototype.update this)
with no luck.
Hmmm, that didn't seem to work either. I'm not getting any error, so it's hard to know what's going wrong.
I have an object, emitter, whose built-in update function is called every cycle to emit particles. I want to override that update with custom behavior (set! (.-update emitter) (fn [] ...custom-behavior... now call regular update function)))
I think I need to set emitter's ParticleClass, and this would be the new update for that, not for the emitter itself.
Is there a compiler API that can turn /home/rauh/dev/srs-om/src/cljs/srs_c/components/learn/initial/home.cljs
(obtained from &env
) into
?
Actually I pick it up from (:file (meta &form))
in my log macro. But it gives me the absolute path. I want to be able to log it into the console with line number (`:line`) so that I can jump to the source
Yeah I guess I can log the cljs file, but I'd still need the translated path. I'll check what Chrome makes clickable...
Ok so I'd still need the ?rel=...
or ?zx=...
parameter to make it clickable. But yeah I'd actually want the .cljs
not the .js
as I posted above
I guess I can throw an error and get the stacktrace to get the location. But that's pretty ugly
(picked up work again on https://github.com/rauhs/klang )
It first logs to an array and you can view the messages. Then you can click messages of interest and it'll dump all local bindings, the log message params and filename+line number
Yeah if you dump chrome a http:.....
and that's a source file loaded it won't just load the file in a new tab but instead jump to the source in the source panel of the developer tools
but don't you want the raw filename? why would you ever want to jump to the generated .js?
Yeah but if I logged everything to the console the console would be swamped with messages. So klang just logs to memory and you can then dump the local bindings (which can be many bindings) to the console.
So only fatal,error, warn stay in production and then they'll call a function that can report the error.
but I'm curious: how do you send something to the console that chrome makes clickable as a link?
Yeah kind of, but when I started work on klang many years ago devtools didn't work for me. Now it does 🙂
file:///home/rauh/dev/srs-om/src/cljs/srs_c/components/learn/initial/home.cljs
seems to work no?
seems like you should be able to create something with some subs
and document.location
It works, but is there a way to do this more elegantly, or is this as good as it gets?
@thheller Anyways... I revived my :trace
setting (`(goog.debug.getStacktrace)`) that attaches a full blown stacktrace to every log call. So once that meta data is dumped to the console I can click the entire stacktrace along. Much easier.
(defn ElectroParticle [x y args] (this-as this (js/Phaser.Particle.call this x y args)))
(gobj/extend (.-prototype ElectroParticle) js/Phaser.Particle.prototype #js {:update the-update-fn})
When I println an object to console, I just get #object[Object [object Object]]
. Is there a handy way to get a more useful printing of the object?
Good to know. BTW, something funny is going on with the gobj/extend version you gave me; some of the properties that should be set by the constructor aren't getting set. Not a big deal since my other version is working, but wanted to see if there's something subtle I'm maybe missing.
@puzzler I don't know what phaser expects so can't say much. I use the gobj/extend
version for my react components and it works without issues
Anyone using clojurescript for writing back-end (e.g. Node.js) apps ? I haven't really seen an example using Boot or one which actually considered how to have a REPL
@pseud not boot but https://github.com/thheller/shadow-devtools/wiki/ClojureScript-for-node.js-scripts has a REPL built-in
https://github.com/thheller/shadow-devtools/wiki/REPL this works in boot
Hi everyone! I started a new podcast "5 minutes of React" - many of us work with React itself and I think it might be interesting to keep up with React hot news and topics for ClojureScript community, so I share it here. https://5minreact.audio
should the be a way with ClojureScript to use this https://github.com/ianstormtaylor/slate-auto-replace/blob/master/lib/index.js as a foreign lib? I can’t figure out how to provide the type-of
dependency…
well if you use many cljsjs
packages the odds are pretty high that your bundle is bigger than it needs to be
var React = require("react");
var ReactDOM = require("react-dom");
window["React"] = React;
window["ReactDOM"] = ReactDOM;
Did anyone try to compile lein project with javasctipt modules using cljsbuild? Does cljsbuild support javascript modules feature?
The ClojureScript compiler supports JavaScript modules (either Common JS or ES6 variety) with the :foreign-libs
compiler option (https://clojurescript.org/reference/compiler-options#foreign-libs). You'll just need to add that option to your cljsbuild profile.
Coming from boot, I'm wondering lein-figwheel has an option to emit an audible signal or a visual clue (say, in the taskbar) if there's a clojurescript compiler warning or error
The context is working with react-native, where the On-Screen Display doesn't always show reliably
I'm not sure what the "right" way to do that would be, but you could do something hacky like
while inotifywait -q -e modify figwheel_server.log >/dev/null
do
zenity --info --text "$(tail figwheel_server.log)"
done
haha not a bad idea
I'm totally going to try this 🙂
@qqq if that go block has an infinite loop yes (and doesn’t have any chances to block)
I’m using latest clojurescript in the project with clojure 1.8. Is there a function in CLJS that can transform new namespaced maps into “old” syntax?
@dnolen : suppose I want to instrument a function to say: run this function for 100ms, kill it if it does not complete; is the only wan to do this to insert the check in the function itself?
@jr my problem is when I evaluate something with CIDER, something that comes from cljs side and has new map syntax, I can’t format it using cider-format-edn, because it uses Clojure. and the Clojure version available to cider is 1.8. So, I need something that can translate new map syntax to old map syntax
@qqq is that Node or the browser?
if you’re running in Node, there’s a V8 API to interrupt evaluation. Lumo 1.4 shipped with the ability to kill infinite loops at the REPL thanks to it
@ag there is a flag *print-namespace-maps*
that can turn that printing style on and off btw
(set! *print-namespace-maps* false)
?
I’m not sure if that works in cljs
@dnolen @anmonteiro : I should have clarified. This is the browser. Chrome in particular.
Can "webworker" threads be killed by it's parent, or do they also have to terminate on their own ?
qqq: You can launch and terminate and communicate with web workers. But you can't interrupt the currently running logic of a synchronous context running within the worker.
@qqq I believe if all the code is under your control, you could wrap all functions potentially called from that root function into core.async go blocks and then write your own “interruptible” dispatcher: https://github.com/clojure/core.async/blob/master/src/main/clojure/cljs/core/async/impl/dispatch.cljs
and yes, web worker can be terminated: https://developer.mozilla.org/en-US/docs/Web/API/Worker/terminate
ah, forget my post, that core.async won’t work for tight infinite loops as dnolen correctly pointed out, those won’t be broken as core.async tasks
I just changed cljs.spec
to cljs.spec.alpha
now would be a good time to try master - would like to cut a release for this
@dnolen just tested master clojurescript with my lib[1] using spec both in clojure and clojurescript, and I confirm it started to work again: https://github.com/binaryage/cljs-oops/tree/spec-ulation
Can anyone tell me why:
cljs.user> (set! *print-namespace-maps* false)
false
cljs.user> *print-namespace-maps*
true
upd:
it seems I have to do something like this:
(binding [*print-namespace-maps* false]
(pprint x))
@ag I can’t repro what you are seeing.
$ java -jar cljs.jar -m cljs.repl.node
ClojureScript Node.js REPL server listening on 53388
To quit, type: :cljs/quit
cljs.user=> *clojurescript-version*
"1.9.521"
cljs.user=> (set! *print-namespace-maps* false)
false
cljs.user=> *print-namespace-maps*
false