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 -- 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.
