Closed Ravenstine closed 5 years ago
It's wrong usage of the API.
# @yield if the block has no parameters it's `instance_exec`d, otherwise it's called with `self`
What this means is you have to do this:
Browser::Socket.new "ws://localhost:9000/ws" do |s|
s.on :close do
debug "whatever"
end
end
I've been writing my own client-side MVC for my amusement, and came across this problem.
Here is a controller. Note, this is not a Rails controller but inherits from a class called ApplicationController which doesn't do anything at the moment.
When the controller is initialized, the debug method is called and inserts "yo" into the DOM.
However, when the block passed to Browser::Socket calls the same controller method, I get this error:
Uncaught NoMethodError: undefined method
debug' for #I'm pretty sure this is different behavior than what's displayed in YARV(or RubySpec for that matter).
I cannot tell if this is a problem with opal-browser or Opal itself. If this is a result of the nature of JavaScript, perhaps it should be documented somewhere