add reference/javascript-interop-ref.adoc#95
add reference/javascript-interop-ref.adoc#95mobileink wants to merge 9 commits intoclojure:masterfrom
Conversation
Signed-off-by: Gregg Reynolds <reynolds-gregg@norc.org>
Signed-off-by: Gregg Reynolds <reynolds-gregg@norc.org>
Signed-off-by: Gregg Reynolds <reynolds-gregg@norc.org>
Signed-off-by: Gregg Reynolds <reynolds-gregg@norc.org>
Convert some of the Java lingo to Javascript (e.g. s/instance/object/) FIXME indicates places where content is missing or verified DELETE indicates code from the clj doco that i think does not apply to cljs Signed-off-by: Gregg Reynolds <reynolds-gregg@norc.org>
Signed-off-by: Gregg Reynolds <reynolds-gregg@norc.org>
Signed-off-by: Gregg Reynolds <reynolds-gregg@norc.org>
Signed-off-by: Gregg Reynolds <reynolds-gregg@norc.org>
…into interop-ref
|
@mobileink Thanks! This draft is looking pretty good! I'd be happy to contribute when you get to the point where you are interested in feedback. |
|
Thanks for reminding me. Life intervened, but I hope to get back to this soon. |
|
I am very much looking forward to this, we really need this guide. Any way other people can help you, @mobileink ? |
|
|
||
| Non-goals: | ||
|
|
||
| * user guide - that goes in link:../guides/javascript-interop-guide.adoc[Javascript Interop Guide] |
There was a problem hiding this comment.
(when somebody creates it :))
There was a problem hiding this comment.
the guide could well be based on http://funcool.github.io/clojurescript-unraveled/#host-interoperability (and the partly outdated http://www.spacjer.com/blog/2014/09/12/clojurescript-javascript-interop/)
| ---- | ||
| #js {:a 1 :b 2} | ||
| -> #js {:a 1, :b 2} | ||
| (js-obj :a 1 :b 2) |
There was a problem hiding this comment.
I think that for js-obj we need to use string keys, otherwise we end up with the js object { ':a': 1, ':b': 2 }, which likely is not desriable. Worth pointing out that #js converts :kwd -> "kwd" (and ::kwd -> ":kwd".
We should also mentioned that #js is not recursive, i.e. I need #js {:child #js {:isKid true} :isParent true}
| has (proto)types, objects, field properties, and method properties. | ||
| In the following, we will drop "property" and refer to "fields" and | ||
| "methods". | ||
|
|
There was a problem hiding this comment.
also remind the user that objects in the global context need to be accessed via js/, contrary to the direct access in JS itself?
|
|
||
| TODO: make this readable | ||
|
|
||
| For interacting with Javascript objects, use `goog.object` rather than `aget` |
There was a problem hiding this comment.
Perhaps also mention https://github.com/binaryage/cljs-oops as an alternative? It is already mentioned at cljs.info/cheatsheet/
| Special form. | ||
|
|
||
| The args, if any, are evaluated from left to right, and passed to the constructor of the class named by Classname. The constructed object is returned. | ||
|
|
There was a problem hiding this comment.
- this:
Note that if Typename is defined within a module, you simply prepend the module name with a dot, just as you would do in JavaScript:
(new myModule.MyType ...)
First draft