This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-03-25
Channels
- # admin-announcements (1)
- # aws (1)
- # beginners (52)
- # boot (78)
- # cider (22)
- # cljs-dev (1)
- # cljsrn (6)
- # clojars (23)
- # clojure (51)
- # clojure-austin (2)
- # clojure-china (2)
- # clojure-dusseldorf (2)
- # clojure-russia (101)
- # clojure-sg (2)
- # clojure-uk (2)
- # clojurescript (53)
- # core-logic (14)
- # cursive (1)
- # editors (4)
- # hoplon (324)
- # jaunt (1)
- # juxt (4)
- # leiningen (2)
- # mount (17)
- # off-topic (4)
- # om (15)
- # onyx (15)
- # parinfer (4)
- # proton (5)
- # re-frame (26)
- # reagent (24)
- # ring-swagger (1)
- # slack-help (5)
- # spacemacs (2)
- # untangled (10)
@domkm: you can use js*
😛
Anybody seen this exception:
java.lang.IllegalStateException: Can't change/establish root binding of: *cljs-repl-env* with set
@slotkenov: you need to start the repl server using the cljs-repl
task then in a client boot repl --client
you can call (start-repl)
ahh, I forgot the -c
option for boot repl
. Didn’t know that was mandatory for the cljs-repl
@martinklepsch: thanks
I can get the closure compiler to pick up an object, but not any properties inside that object My externs file goes like this:
var api = function() {};
api.get = function(limit, offset, callback) {};
api
remains in the advanced optimized code, but get
gets scrambled.By the way: you always need an externs file for any external library? Or am I missing something?
@slotkenov: not always: https://github.com/clojure/clojurescript/wiki/Dependencies#using-string-names
here I use it in a generated library to side-step externs complexity: https://github.com/binaryage/chromex#advanced-mode-compilation
until then I will use string names, it might increase :advanced build sizes and slow down javascript property lookups a bit, but it is not an issue in many scenarios, for example if the api is not called too often or file size is not that big deal
you could use something like this to make calling code look just fine when accessing props by string names: https://github.com/binaryage/chromex/blob/master/src/lib/chromex/support.clj#L5-L26
thanks for pointing that out, last time I checked I found some incomplete externs in closure lib, updated by hand
I might eventually support a compilation switch for chromex, to emit non-string property access code, and people could use something like this if they preferred
but right now string access just works(tm), I don’t want to hear from people messing with outdated externs files / using them incorrectly
chrome api calling code is produced through this generator, I would just make this line configurable, and instead of oget I would generate there normal js-interop access https://github.com/binaryage/chromex/blob/master/src/lib/chromex/wrapgen.clj#L70
suddenly I'm getting "Invalid :refer, var does not exist in file" errors when I compile incrementally, but if I compile from scratch all is well
@martinklepsch: That might just work! I'll give it a shot later. Thanks.
@martinklepsch: js*
works but compiler options :language-in :ecmascript6 :language-out :ecmascript3
isn't compiling class declarations
@martinklepsch: Nevermind. It works with simple optimizations (and, presumably, advanced as well) 😄
How can I get js/Notification
's onclick
to work? I posted details to the question on SO: http://stackoverflow.com/questions/36225109/how-can-i-create-a-js-notification-in-clojurescript-that-can-focus-on-the-window
@josh.freckleton: I replied on SO
@chrisoakman: You sir, are a saint. I spent so long beating my head against this! However, (.focus js/window)
still doesn't focus. Even if I run that straight in the figwheel REPL. Any idea why not? (it does however work if it's straight javascript...)
I'm not familiar with window.focus()
generally
although the code I posted on that SO thread compiles down to return window.focus();
directly (the return
because it's the last expression in that function)
I have a build:
{
:builds {:prod
{:id "prod"
; The path to the top-level ClojureScript source directory:
:source-paths ["src-cljs"]
:figwheel false
; The standard ClojureScript compiler options:
; (See the ClojureScript compiler documentation for details.)
:compiler {
:output-to "resources/public/main.js"
:asset-path "out"
:main "tanks.core"
:optimizations :advanced}}
:dev {:id "dev"
; The path to the top-level ClojureScript source directory:
:source-paths ["src-cljs"]
:figwheel true
; The standard ClojureScript compiler options:
; (See the ClojureScript compiler documentation for details.)
:compiler {
:output-to "resources/public/main.js"
:asset-path "out"
:main "tanks.core"
:optimizations :none
:pretty-print true}}}}
@chrisoakman: hm... window.focus()
should force the browser to jump to that window/tab automatically. It works just fine in js. I'm traking the problem, and here's an insight. Run the following code:
(do (js/alert "an alert")
(.focus js/window)
(.log js/console "console log"))
and notice that the console.log
works, but neither of the other lines. I could see the non-functioning lines being used for spammy purposes, and so maybe the browsers are inhibiting them some way? How do I get around this?EDIT: ah weird, I just closed that tab, and re-opened it, and now alerts work, but not focus...
@josh.freckleton: I'm not sure about window.focus()
; my gut says it's not a CLJS thing though
given the context you've shared here
@chrisoakman: I'll get it, thanks for all the help
you're welcome; anytime
@chrisocowan: if you're curious at all, I think I've found out that window.focus
only works if it's from a user-initiated action. For some reason, there's something about your (awesome) cljs code you helped me with which makes it think that notification clicks aren't user initiated. The following works, and I just need to convert to proper cljs now:
(do (js* "
Notification.requestPermission(function (permission) {
if (permission !== 'granted') return 'false';
var notification = new Notification('Here is the title', {
icon: '',
body: 'Some body text',
});
notification.onclick = function () {
window.focus();
return 'true';
};
});"))
wait, false alarm, it's broken again...
hrm, it looks like in order for the focus to work, some chrome tab needs to have focus when I click on the notification. If not, nothing happens until I click on a chrome tab, and then the notification. Weird.