Clojurescript and Google Closure: how to properly require a namespace or import a class?

I noticed in tut Clojurescript 101 that you can use closure classes, for example:

(ns async-tut1.core
  (:import [goog.net XhrIo]))

But there is a note that says:

Note: the import is for this use case only, you never use it with ClojureScript libraries

What does it mean? As I understand it, you should not import classes this way. I'm right? If so, how would you do it? Many thanks.

+4
source share
1 answer

If you want to import Closure classes, you use import, if you import functions or vars, then you use require or use:

(ns async-tut1.core
  (:require [goog.events :refer [listen] :as ev])
  (:import [goog.net XhrIo]))

, import - ( google).

+9

Source: https://habr.com/ru/post/1541417/


All Articles