Closed zw963 closed 3 years ago
@zw963 you're probably passing a full-blown Hash
object to a native function, instead try converting it to native before sending it: x.JS.uploader({…}.to_n)
It worked!
If there exist some document told me about the difference about following arg1
and arg2
, that will
good.
Native(`jsObject`).method(arg1)
# with
`jsObject`.JS.method(arg2)
What I think is:
form1: a native
object, invoke a auto created
ruby method(use method missing), which accept a ruby Hash
object.
form2: a js object, use a special Opal Lexical token(JS), invoke a native
function, only accept native
arguments
@elia , Does I understand basically correct ?
Thanks
# example 1
Native(`jsObject`).method(arg1)
# example 2
`jsObject`.JS.method(arg2)
I guess maybe Native wrapper like example 1
, which invoke to_n
when construct
the method_missing for us, but, I think we should mention this in document, Or,
just keep same behavior as example 2
, we always invoke to_n
ourself when
invoke a native js function.
Do you think, @elia ?
I think the better solution is add those content in Opal document, as described in @fkchang this post:
While String, Numeric, and Array objects in Opal are implemented directly with the corresponding Javascript types, Hash requires more to support all the features of Ruby's Hash thus we need to use to_n() to convert it back to a plan Javascript objects when passing to native Javascript functions.
this is resolved, so please close this!
this is resolved, so please close this!
Thank you.
Following is attempt to introduce Opal in my project only for a single CDN uploader module:
The error message is:
this is caused by when invoke
init
method, it not recognize the@domain
instance variable.If replace
With
@domain is recognized.
I think there maybe some issue happen with JS ...
Following is Opal version info: (I notice opal-sprockets exist two version)