On Thursday, 19 November 2015 18:27:42 UTC-2, Karsten Schmidt wrote: > Oh, and if these chrome props end up mangled in advanced compilation, > you should use `aget` or find/make a little externs file... > > (.addListener (aget (aget js/chrome "commands") "onCommand") (fn [e] ...)) > > > On 19 November 2015 at 20:20, Karsten Schmidt <[email protected]> wrote: > > AFAIK this is NOT how you refer to nested object properties in CLJS: > > > > js/chrome.commands.onCommand > > > > use this instead: > > > > (.addListener (.. js/chrome -commands -onCommand) (fn [e] ...)) > > > > K. > > > > On 19 November 2015 at 17:07, Marcelo Almeida > > <[email protected]> wrote: > >> Copied from my post on StackOverflow > >> (http://stackoverflow.com/q/33808596/1814970). > >> > >> > >> I have the following code, in a new extension I am working on: > >> > >> (.addListener js/chrome.alarms.onAlarm (fn [alarm] (.log js/console > >> alarm))) > >> (.addListener js/chrome.commands.onCommand (fn [command] (.log js/console > >> command))) > >> (.addListener js/chrome.browserAction.onClicked (fn [] (.log js/console > >> "clicked!"))) > >> > >> My :cljsbuild looks like this: > >> > >> {:id "background" > >> :source-paths ["src/folder/background"] > >> :compiler {:output-dir "resources/public/js/compiled/background" > >> :output-to > >> "resources/public/js/compiled/background/background.js" > >> :main folder.background.background > >> :optimizations :advanced > >> :pretty-print true > >> :source-map > >> "resources/public/js/compiled/background/background.js.map" > >> :externs ["resources/public/js/chrome_extensions.js"]}} > >> > >> The code is exactly in the order shown. The bizarre thing is that the > >> first and third lines work, while the second does nothing. My > >> manifest.json (relevant parts) looks like this (there is no parsing error): > >> > >> "background": { > >> "scripts": [ > >> "path/to/compiled/file.js" > >> ] > >> }, > >> "permissions": [ > >> "alarms", > >> "commands" > >> ], > >> "commands": { > >> "do-something": { > >> "suggested_key": { > >> "default": "Alt+Shift+D" > >> }, > >> "description": "Do it!" > >> } > >> } > >> > >> I have advanced compilation on and I have the correct extern file (this > >> works, except for this particular case). > >> > >> Last, but not least, I did a JavaScript version of this and the same thing > >> works. How can it be?? > >> > >> chrome.commands.onCommand.addListener(function (command) { > >> console.log(command); > >> }); > >> > >> Thanks in advance! > >> > >> -- > >> Note that posts from new members are moderated - please be patient with > >> your first post. > >> --- > >> You received this message because you are subscribed to the Google Groups > >> "ClojureScript" group. > >> To unsubscribe from this group and stop receiving emails from it, send an > >> email to [email protected]. > >> To post to this group, send email to [email protected]. > >> Visit this group at http://groups.google.com/group/clojurescript. > > > > > > > > -- > > Karsten Schmidt > > http://postspectacular.com | http://thi.ng | http://toxiclibs.org > > > > -- > Karsten Schmidt > http://postspectacular.com | http://thi.ng | http://toxiclibs.org
Thanks for your answer! I've been bashing my head against this for a while now and all of a sudden my trivial example, which was not working, is working. The project is here: https://github.com/marcelocra/chrome-extension-cljs-example. The nested syntax I used does work (looked into it and it seems that both are valid and both gave me the same results). Regarding mangling, I am using the chrome_extensions.js extern provided in the Google Closure repo (its names are not mangled in the output js, even in advanced mode). I will continue adding stuff to this basic project and if I manage to reproduce the problem again, I post it here. Thanks again! -- Note that posts from new members are moderated - please be patient with your first post. --- You received this message because you are subscribed to the Google Groups "ClojureScript" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/clojurescript.
