Opal::Processor.load_asset_code(::Rails.application.assets, 'components')
"if (typeof(Opal) !== 'undefined') { Opal.loaded([\"opal\",\"corelib/runtime.self\",\"development/react.self\"]); Opal.load(\"components\"); }"
regardless of whether i am in opal 9, or opal 10
this is then sent to the ruby racer for evaluation.
everything works fine
but
in opal 10, on the top level module "React" seems to be defined... like wise only the the top level Component module is defined.
@ctx.eval("Opal.React.IsomorphicMethods.$some_method...")
which now wants to look like this:
@ctx.eval("Opal.React.$$scope.get('IsomorphicMethods').$some_method...")
Is there a better way of dynamically decided which to use other than doing this:
if @ctx.eval("Opal.React.IsomorphicMethods")
... old way
else
... new way
end
How far back was $$scope.get defined (I want to stay compatible with Opal 0.8 +)
$$scope.get
works back to 0.8, but trying is the right way to find out :P
Module#const_get
if it's implemented on older versions… that way you use a ruby API instead of an internal Opal behavior