Skip to content
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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

mobileink
Copy link

First draft

Gregg Reynolds added 9 commits June 26, 2017 12:18
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]>
@mfikes
Copy link
Member

mfikes commented Nov 17, 2017

@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.

@mobileink
Copy link
Author

Thanks for reminding me. Life intervened, but I hope to get back to this soon.

@holyjak
Copy link
Contributor

holyjak commented Jan 21, 2018

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]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(when somebody creates it :))

Copy link
Contributor

@holyjak holyjak Jan 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

----
#js {:a 1 :b 2}
-> #js {:a 1, :b 2}
(js-obj :a 1 :b 2)
Copy link
Contributor

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".

Copy link
Contributor

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`
Copy link
Contributor

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.

Copy link
Contributor

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 ...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants