These are chat archives for opal/opal

Jun 2016
Yehonathan Sharvit
Jun 24 2016 03:10
@catmando how did you do that?
Mitch VanDuyn
Jun 24 2016 03:11
I think instructions are in opal readme
I'm about to go to bed. I'll po
Meantime look at SNOBOL gem. It's isomorphic. But I agree it's a bit tricky
Drew Hamlett
Jun 24 2016 11:59
Hello. I'm not able to see any output with Opal 0.9.4. I just started a project with Opal server and everything is getting compiled but the module isn't running
Opal.modules["application"] = function(Opal) {
  Opal.dynamic_require_severity = "error";
  var OPAL_CONFIG = { method_missing: true, arity_check: false, freezing: true, tainting: true };
  var self =, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice;

  Opal.add_stubs(['$require', '$puts']);
  return self.$puts("hello");
i see that but it's not running the code
I dont' remember having an issue with this before
Drew Hamlett
Jun 24 2016 12:04
    <script src="/assets/application.js"></script>
If it put that everything is working. so not sure what's happening
Elia Schito
Jun 24 2016 12:25
@drewhamlett sprockets compiles files only to modules, that's after 0.8 iirc, to allow require order to be respected
the solution you're using is correct, the official API is Opal.load('application')
I have a solution for that in the works but it's not released yet : )
Bernhard Weichel
Jun 24 2016 14:10
what is the best way to capture keyboard events. E.g. if one enters ctrl-R (or cmd-R) I would like to do a refresh in my application, not in the browser window,
tried to use '/events' do |es|
      es.on :message do |e|

      es.on :keydown do |e|
        alert "keydown #{}"
      es.on :customs: do |e|
        alert "custom #{}"
Ilya Bylich
Jun 24 2016 14:39
@bwl21 I think you are using a wrong class :smile:
EventSource is not for keyboard events, it's for server-side events
Jamie Gaskins
Jun 24 2016 16:48
@bwl21 Assuming you're using opal-browser, you might be able to do it like this:
$window.on :keydown do |e|
  if (e.meta? || e.ctrl?) && e.code == 82 # Ctrl/Cmd + R
refresh_app would be your own defined behavior
Bernhard Weichel
Jun 24 2016 18:01

@jgaskins: you brought me to the right track. Thanks. Eventually this code works:

    $window.on :keydown do |e|
      if (e.meta_key || e.ctrl_key) && (e.key_code == 82) # Ctrl/Cmd + R

Is there somwhere a documentation wehre I could have find this:
is $windowequivalent to Element.find(`window`) ? Where is this global set? How to avoid name conflicts with an application global named $window?

I found the name of e.meta_key etc. by debugger.