Comments (6)
I'd encourage you to create a separate library for ClojureScript, it honestly seems easier.
from potemkin.
no problem
from potemkin.
@davesann if you've managed to do this for vars and functions in cljs, would you mind publishing it? Looks like there would be some interest more broadly.
from potemkin.
I haven't looked at this in a while. But it worked fine for my purposes. Very basic macros as I mentioned. I haven't pushed this to github yet. It was too small... but you are free to use as you wish if it meets your needs.
(ns dsann.potemkin.cljs.namespaces)
(defmacro import-def
"import a single fn or var
(import-def a b) => (def b a/b)
"
[from-ns def-name]
(let [from-sym# (symbol (str from-ns) (str def-name))]
`(def ~def-name ~from-sym#)))
(defmacro import-vars
"import multiple defs from multiple namespaces
works for vars and fns. not macros.
(same syntax as potemkin.namespaces/import-vars)
(import-vars
[m.n.ns1 a b]
[x.y.ns2 d e f]) =>
(def a m.n.ns1/a)
(def b m.n.ns1/b)
...
(def d m.n.ns2/d)
... etc
"
[& imports]
(let [expanded-imports (for [[from-ns & defs] imports
d defs]
`(import-def ~from-ns ~d))]
`(do ~@expanded-imports)))
from potemkin.
@davesann Thanks for sharing.
from potemkin.
@davesann thanks for sharing :)
from potemkin.
Related Issues (20)
- Source for 0.3.13 HOT 2
- Macros define var even if not evaluated HOT 1
- Any chance of a version of import-vars that works for cljc? HOT 1
- Empty defprotocol+ bodies cause definition to not occur HOT 2
- Add examples for optional names to README
- Reconsider ClojureScript support? HOT 1
- Document how `import-vars` interacts with direct-linking and namespace reloading HOT 2
- def-derived-map has a broken hashCode if any key is nil HOT 3
- Metadata handling by `postwalk` in some cases
- Reliable JVM crash using definterface+ HOT 4
- wow, awesome naming! HOT 3
- def-map-type's predefined count doesn't run in constant time HOT 1
- Boxed math warning at unchecked-add
- Question: why so many ancestors difference betwence Clj map and a PotemkinMap? HOT 1
- Top-level namespace breaks jdeps analysis HOT 2
- docs: describe defprocotol+ HOT 9
- docs: add caveat about import-vars? HOT 2
- `def-map-type` breaks in namespaces that shadow core Clojure methods like `instance?`
- Potential breakage
- potemkin maps are `(instance? java.util.Iterator)` but clojure maps are not
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from potemkin.