These are chat archives for opal/opal

23rd
Jan 2018
Billy.Zheng
@zw963
Jan 23 2018 08:04
Thank @elia a lot for wonderful Opal. Hope see Opal 1.0 is released in the future.
G. Gibson
@mistergibson
Jan 23 2018 19:53
Question: can I call a ruby object from js directly? example: @timer_handle = 'setInterval(#{self}.tick(),2000)' ... ?
Simon George
@sfcgeorge
Jan 23 2018 19:56
Yes :)
do_later = $$[:setTimeout] # Accessing the "setTimeout" property
do_later.call(->{ puts :hello}, 2000)
do_later.call(->{ tick }, 2000)
do_later.call(method(:tick), 2000) # maybe
G. Gibson
@mistergibson
Jan 23 2018 19:57
Sweet , thanks :)
ok, but not the way I expressed it in my question right?
G. Gibson
@mistergibson
Jan 23 2018 20:01
Excellent, and much simpler than I thought it was - thanks again :)
Simon George
@sfcgeorge
Jan 23 2018 20:01
That's from Ruby calling a JS function. If you mean from JS calling a Ruby function then no I don't think so. But you can do from Ruby inline JS calling Ruby
`setTimeout(#{method(:tick).to_proc}, 500)`
Note the backticks
G. Gibson
@mistergibson
Jan 23 2018 20:02
ok, sure - that's cool
G. Gibson
@mistergibson
Jan 23 2018 20:06
That all seems very straight forward. at first I was just unsure about HOW to refer to an object/method with respect to the native call. Thanks for clarifying.