-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add reference/javascript-interop-ref.adoc #95
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Gregg Reynolds <[email protected]>
Signed-off-by: Gregg Reynolds <[email protected]>
Signed-off-by: Gregg Reynolds <[email protected]>
Signed-off-by: Gregg Reynolds <[email protected]>
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 <[email protected]>
Signed-off-by: Gregg Reynolds <[email protected]>
Signed-off-by: Gregg Reynolds <[email protected]>
Signed-off-by: Gregg Reynolds <[email protected]>
…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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(when somebody creates it :))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 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