Skip to content

Instantly share code, notes, and snippets.

@aymanosman
Created January 10, 2014 22:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aymanosman/8364344 to your computer and use it in GitHub Desktop.
Save aymanosman/8364344 to your computer and use it in GitHub Desktop.
(ns example.core
(:require [serialport :as comPort]) ;; As a side note, why does the :as clause add a second call to goog.require??
)
(def com (js.require "serialport")) ;; Using a dot instead of a / works incidentally
(def device-wrong1 (com.SerialPort. "COM1"))
(def SerialPort (.-SerialPort com))
(def device-correct1 (SerialPort. "COM1")) ;; Must I resort to this...
(def device-correct2 (example.core.com.SerialPort. "COM1")) ;; ...or this?
(def device-wrong2 (com/SerialPort. "COM1"))
(def device-wrong3 (new com.SerialPort "COM1"))
(comment
// Compiled by ClojureScript 0.0-2080
goog.provide('example.core');
goog.require('cljs.core');
goog.require('serialport');
goog.require('serialport'); // Second added by :as clause in ns :require
example.core.com = require("serialport");
example.core.device_wrong1 = (new com.SerialPort("COM1"));
example.core.SerialPort = example.core.com.SerialPort;
example.core.device_correct1 = (new example.core.SerialPort("COM1"));
example.core.device_correct2 = (new example.core.com.SerialPort("COM1"));
example.core.device_wrong2 = (new com.SerialPort("COM1"));
example.core.device_wrong3 = (new com.SerialPort("COM1"));
// Compiled by ClojureScript 0.0-2127
goog.provide('example.core');
goog.require('cljs.core');
goog.require('serialport');
goog.require('serialport');
example.core.com = require("serialport");
example.core.device_wrong1 = (new example.core.com.SerialPort("COM1"));
example.core.SerialPort = example.core.com.SerialPort;
example.core.device_correct1 = (new example.core.SerialPort("COM1"));
example.core.device_correct2 = (new example.core.com.SerialPort("COM1"));
example.core.device_wrong2 = (new com.SerialPort("COM1"));
example.core.device_wrong3 = (new example.core.com.SerialPort("COM1"));
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment