Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Elia Schito
@elia
the commented lines should not be useful
G. Gibson
@mistergibson
@elia : thanks, I'll try that
yeah, that worked great
first time - sweet
@elia thanks - now I see a known good on how to do it
Elia Schito
@elia
👍🏼
G. Gibson
@mistergibson
I don't think it loads 'corelib' though - no Marshall::dump available - I'm going to dork with it some
thanks for your help - I just found out about Opal yesterday
So don't like JS ... a hobbled language by comparison
Elia Schito
@elia
try adding require 'opal/full' on top of everything
G. Gibson
@mistergibson
ok
G. Gibson
@mistergibson
I'm curious if anyone has tried opening up a websocket from within Opal ... anyone?
I have a JavaScript lib for it, but I was wondering about moving it over to Opal code.
G. Gibson
@mistergibson
Also - does Opal make use of JavaScript co-routines? ... like soft 'fiber' implementation?
Forrest Chang
@fkchang
G. Gibson
@mistergibson
@fkchang Sweet - thanks
G. Gibson
@mistergibson
Getting odd error 'append_path' not defined for Opal : https://gist.github.com/mistergibson/bc346c3c56833b0ce7014d9c58e384df
G. Gibson
@mistergibson
I'm not sure if it is a) pilot error (most likely), b) opal-browser bug, or c) opal bug.
G. Gibson
@mistergibson
OK - figured it out. Pilot error as usual. Odd thing though - even though I required 'browser/socket' in the bootstrap file compiled to .js - I had to do a Opal.eval("require 'browser/socket'); to make the constant get defined in the Browser console.
is this a lazy-loading feature?
Elia Schito
@elia
That’s strange, can you share the whole code and compiling process?
G. Gibson
@mistergibson
Sure, I'll whip up a gist on it all
G. Gibson
@mistergibson
Here you go - this is what I did and what I got: https://gist.github.com/mistergibson/37f7a3f0afbd19b1d138d1544ca5ac5a
G. Gibson
@mistergibson
Also note: when I just did a compile with '--gem opal-browser' instead of including the two dirs, I'd get 'add_method' undefined for Opal in the Browser.
G. Gibson
@mistergibson
@elia : Any thoughts thus far on what might be going on with this?
G. Gibson
@mistergibson
Also: even though I do a Opal.eval("require 'date'"); DateTime is still undefined.
Ilya Bylich
@iliabylich
@mistergibson --gem option is designed to be used with gems that are not compatible with opal
So by passing this option you include lib directory of the gem to the load path of the Opal
But this gem is designed to be used directly by Opal. It has all files in the opal directory (and the lib directory contains the code the pushes opal dir to the opal's load path)
If you really want to use opal executable you can write something like
$ opal -I../opal-browser/opal --gem paggio --compile your_code.rb
(if opal-browser is in ../opal-browser)
If you compile it from the ruby code (using opal's builders and compilers) you can simply write require 'opal-browser' before compiling the code to register all paths
G. Gibson
@mistergibson
@iliabylich : OK, I'll try that - thanks for your help
G. Gibson
@mistergibson
@iliabylich : Actually, that didn't work so well. Even after doing Opal.eval("require 'browser/socket'"); => true ... Browser::Socket remains undefined ... hrm
Ilya Bylich
@iliabylich
@mistergibson Don't do eval, it doesn't help. Everything that you need must be required in the main .rb file.
Could you share your file please?
G. Gibson
@mistergibson
Ah, is eval in a differing name space?
I'll cobble a gist for you ...
Sorry for all the pestering - I'm just still giddy with the prospect of coding in Ruby .... IN a webpage! Awesome.
Mitch VanDuyn
@catmando
Is there any known issue (or changes in behavior) in Opal 0.11 around the second parameter of const_get and const_defined?
specifically we have code with const_get(xxx, false) (meaning do not search down tree) and it broke in Opal 0.11
Elia Schito
@elia
@catmando the const lookup was rewritten, as far as you know the new behavior differs from MRI?
Mitch VanDuyn
@catmando
we don't know in detail.... just got a report from @sfcgeorge that code which was working with const_get(xxx, false) or perhaps const_defined? stopped working in 11, until he changed false to true.
that is all I know ATM
Elia Schito
@elia
@catmando ok, that could be a collateral effect of the improved behavior, @sfcgeorge let me know what's that, if it's an actual issue I'd like to look into it
Mitch VanDuyn
@catmando
@elia is there any way to run try opal on older versions?
Simon George
@sfcgeorge

A version selector on Try Opal would be amazingly helpful.

In this case I just know that making the second parameter true made something work in 0.11 that had worked in 0.10. I don't know which one the bug is in though, just because it worked before doesn't mean it was working as intended.

Elia Schito
@elia
@catmando no, but you can run the CLI on any installed version with opal _0.10.5_ -e 'p RUBY_ENGINE_VERSION'