Thanks to visit codestin.com
Credit goes to www.slideshare.net

Clojure on Node
Building a CLI utility
Why?
• Startup speed - Node.js apps start faster
• Easier distribution -- ```npm install -g <app>```
• Way to learn core.async
• AWS Lambda/Google Cloud Functions
(serverless architecture)
• Server-side rendering
ClojureScript build process
*.cljs files *.js file(s)
Google Closure
compiler
ClojureScript
compiler
compiles
cljs->js
compiles
js->optimized-js
Setting up Leiningen
Setting up Leinigen (cont'd)
Hello, World!
Building
Read Eval Print Loop demo
REPL
starts
nodejs process on random port
does this:
and sends user commands to nodejs process, started by
repl-env, over the network socket
used by IDEs
Parsing ars - clj.tools.cli
Parsing args (cont'd)
Interop with Node.js libraries
compiles into
Callbacks
core.async for callbacks
georgewsinger/cljs-callback-heaven/blob/master/src/cljs_callback
core.async for callbacks
(cont'd)
https://github.com/mailhog/MailHog
core.async for promises
Links
• clojars.org/<template-name>/lein-template
=>
```lein new <template-name> <project-name>```
• https://clojars.org/cljs-node/lein-template
• https://clojars.org/cljs-node-app/lein-template
• https://clojars.org/node-cljs/lein-template
• https://clojars.org/node-cli/lein-template
• https://github.com/karolisl/repomaker -- my cljs-node project
• https://github.com/Gozala/node.core -- some helper functions working on node
• https://github.com/GregorStocks/cljs-http-node -- core.async based http client for
node

CLI utility in ClojureScript running on Node.js

Editor's Notes

  • #9 (println #(println "a"))
  • #10 ; this will implicitly set! *cljs-compiler-env* (set! *cljs-repl-env* repl-env) Code for node-repl is javascript inside clojurescript jar, uses net.createServer() (println #(println "a"))