Raskal nickname: Atom Atomic engineer
*he also like quantum physics

#dc comics#batman#dc#bruce wayne#dick grayson#tim drake#batfamily#batfam#dc fanart


seen from Sweden

seen from Brazil
seen from China

seen from Lithuania
seen from China
seen from United States
seen from United States
seen from United States
seen from China

seen from Australia
seen from Poland

seen from United States
seen from China

seen from China
seen from United States
seen from China
seen from United States
seen from United States

seen from United States
seen from United States
Raskal nickname: Atom Atomic engineer
*he also like quantum physics
Clojure Script, Atom Shell, core.async
I have been in a process of setting up an Atom Shell app, where I'd use Clojure Script for both browser (which is the backend in Atom Shell's nomenclature) and renderer sides. Setting this up wasn't as straightforward as I'd hope to, but it can be done.
Using Clojure Script both for browser and renderer side would (hopefully) allowe me to reuse some of the code.
I used Leiningen with a lein-cljsbuild. I've set up two build profiles, one for the browser, another for renderer sides. The biggest challenge here was to make browser.js work with ecent Clojure Script (0.0-2913) and core.async. Depending on the optimization level and target set, I would repeatedly get errors such as:
goog.global.setTimeout undefined TypeError: cannot set property 'unicode' of undefined TypeError: undefined is not a function Cannot read property 'cljs$core$IFn$_invoke$arity$1' of undefined
Some of those errors were caused by core.async's go macro not being properly handled by Clojure Script / Google Closure combo.
Finally, I was able to find excellent blog post from Lauri Personen which showed the right path. In a nutshell, what needed to be done is to set :optimizations to :none, then :target to :nodejs and :output-dir to "out". With that build setup, instead of loading the compiled file directly, I needed to provide a small shim:
// Helper, generated by Clojure Script / Google Closure compiler, // which helps Node.js to load compiled files. require('../out/goog/bootstrap/nodejs') // Entry file which loads all JS files from the "out" directory. require('../js/browser.js') // File which contains the main method. require('../out/kamituel/gallery/browser/main') // Call the main method. console.log('shell.js dependencies loaded. Running _main().'); kamituel.gallery.browser.main._main()
Save this file as "js/shell.js" and point Atom Shell to it as a main file:
{ "name": "Gallery", "version": "0.0.1", "main": "js/shell.js" }
For a reference, the project.clj file:
;; cljs/browser - contains Atom Shell browser side namespaces (backend). ;; cljs/renderer - contains Atom Shell renderer side namespaces (frontend). ;; cljs/common - contains namespaces shared accross browser and renderer. ;; ;; Output files: ;; js/browser.js ;; js/renderer.js ;; out/ - browser's output files ;; ;; js/shell.js contains a shim which helps with loading compiled Clojure Script ;; browser code. (defproject gallery "0.0.1" :plugins [[lein-cljsbuild "1.0.6-SNAPSHOT"]] :dependencies [[org.clojure/clojure "1.6.0"] [org.clojure/clojurescript "0.0-2913"] [reagent "0.5.0-alpha3"] [org.clojure/core.async "0.1.346.0-17112a-alpha"]] :cljsbuild { :builds [ {:id "browser" :source-paths ["cljs/common" "cljs/browser"] :compiler { :output-to "js/browser.js" :optimizations :none :output-dir "out" :target :nodejs :pretty-print true}} {:id "renderer" :source-paths ["cljs/common" "cljs/renderer"] :compiler { :output-to "js/renderer.js" :optimizations :simple :pretty-print true}}]} :aliases {"watch" ["cljsbuild" "auto"]})
With that setup, just run lein watch.
jcouyang starred MacGapProject/MacGap2
Dec 4, 2014
That Handsome Devil - Atom Shell
I will destroy this place if I have to
slamin up against the walls of the bathroom