You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$stdout = Object.new.tap { |obj|
def obj.write(i)
JS.global[:document].write(i)
end
}
Then we can simply use puts, which is convenient.
But how to write to console.log?
Past this point if we use:
JS.global[:document].write "foobar"
It will no longer write to console.log, instead just to primary stdout in the browser.
Is there a way to still write to console.log somehow? Could this be added to FAQ?
If not, could there be a way to show this? I'd like to get debug-like output right
via console.log() as well, so being able to write onto console.log even when having
modified $stdout, would be convenient, in my opinion. Could such a way be added
in addition to ruby.wasm?
The text was updated successfully, but these errors were encountered:
console is a JS global just like document so you can access it the same:
JS.global[:console].log('hello')
Feel free to make whatever shortcut you find comfortable:
# global variable
$console =JS.global[:console]
$console.log('hello')# Kernel patch# (this is where `puts` is defined too)moduleKerneldefconsoleJS.global[:console]endendconsole.log('hello')console.error('bad')
In the FAQ currently we have code like this:
Then we can simply use puts, which is convenient.
But how to write to console.log?
Past this point if we use:
It will no longer write to console.log, instead just to primary stdout in the browser.
Is there a way to still write to console.log somehow? Could this be added to FAQ?
If not, could there be a way to show this? I'd like to get debug-like output right
via console.log() as well, so being able to write onto console.log even when having
modified $stdout, would be convenient, in my opinion. Could such a way be added
in addition to ruby.wasm?
The text was updated successfully, but these errors were encountered: