Given a library code that one wants to work in both the browser and node.js.
When it is using a browser specific API, that is available to node only through
a 3rd party package, how would you re-write this piece of code? Are nested defs
ok/bad/un-acceptable?
(if (exists? js/process)
(do
(
Hello,
I' curious what is a preferable way of accessing properties or methods in
nested JavaScript "namespaces".
Lets assume that external library define such property:
Foo.Bar.Foo2.myProperty in global namespace.
what is idiomatic way of accessing 'myProperty':
(.-myProperty js/Foo.Bar.Foo2)
Avoid dots in the name part of symbols. "js/a.b.c" works to reference "a.b.c"
by value (i.e. without calling it), but it's not idiomatic. Prefer (.. js/a -b
-c), or using your examples:
(.. js/Foo -Bar -Foo2 -myProperty)
(.. js/Foo -Bar -Foo2 myMethod)
The "js" pseudo-namespace is special becau
why is it not considered idiomatic, I see that pattern used all the time.
Doesn't clojure itself use fq namespaces occasionally? (just no js prefix)
On Thursday, August 28, 2014 5:45:55 PM UTC-4, Francis Avila wrote:
> Avoid dots in the name part of symbols. "js/a.b.c" works to reference "a.b.c
Sounds good, thank you. Of course I agree, that using dots (like in
"(js/console.log x)") is faster to write.
W dniu czwartek, 28 sierpnia 2014 23:45:55 UTC+2 użytkownik Francis Avila
napisał:
> Avoid dots in the name part of symbols. "js/a.b.c" works to reference "a.b.c"
> by value (i.e. witho