ClojureScript split one namespace into multiple files

I read this thread but it seems that there is no load

u in ClojureScript load-file

. Can you separate one namespace from multiple files?

The reason I want to do this is because I am using Om and I want to separate the components into different files. I can do this with separate namespaces, but then I would have to write the same at the beginning of each file, and also the only way to call these components in the main file:

(:require [some-project.sidebar :as sidebar])

...

(om/build sidebar/sidebar app-state)

      

i.e. I have to put a namespace before every component name that doesn't look pretty. Any ideas on how to improve it? I'm new to Clojure and ClojureScript, so maybe I'm missing something obvious?

+3


source to share


1 answer


There are a few notes here.



  • You can use: refer to your: need to import unqualified vars into namespace. It's okay to have multiple, but can quickly get unwieldy if you try to do it for everything.
  • Clojure applications are often structured in a tree like fashion, where the main namespace requires subnamespaces and so on, so you don't necessarily need to import the same namespaces into every namespace.
  • Even if it were possible to split the namespace into multiple files, it would not be idiomatic Clojure. One file = one namespace is the norm.
  • If you want, you can define vars from one namespace to another to create the "master" namespace in other namespaces.
  • If you want to minimize the amount of imports you need to do, shrink the namespace and make them larger.
+3


source







All Articles