These are chat archives for opal/opal

19th
Mar 2018
Elia Schito
@elia
Mar 19 2018 00:04
@catmando can you give me some more context? I see the backtrace:
⤑ opal -ve '[1,2,nil].sort'                                                    ~
Opal v0.11.0

/private/var/folders/w0/yjfqr9n94ld7ft4j3hlz_fsm0000gn/T/opal-nodejs-runner-20180319-9469-1ugk25o:5022
      throw exception;
      ^
ArgumentError: comparison of 2 with nil failed
    at /private/var/folders/w0/yjfqr9n94ld7ft4j3hlz_fsm0000gn/T/opal-nodejs-runner-20180319-9469-1ugk25o:13586:16
    at Array.sort (native)
    at Array.$$sort [as $sort] (/private/var/folders/w0/yjfqr9n94ld7ft4j3hlz_fsm0000gn/T/opal-nodejs-runner-20180319-9469-1ugk25o:13582:27)
    at /private/var/folders/w0/yjfqr9n94ld7ft4j3hlz_fsm0000gn/T/opal-nodejs-runner-20180319-9469-1ugk25o:21634:22
    at Object.<anonymous> (/private/var/folders/w0/yjfqr9n94ld7ft4j3hlz_fsm0000gn/T/opal-nodejs-runner-20180319-9469-1ugk25o:21635:3)
    at Module._compile (module.js:660:30)
    at Object.Module._extensions..js (module.js:671:10)
    at Module.load (module.js:573:32)
    at tryModuleLoad (module.js:513:12)
    at Function.Module._load (module.js:505:3)
Mitch VanDuyn
@catmando
Mar 19 2018 00:05
I dont :-)
I am looking at it in an exception handler like this:
...
rescue Exception => e 
   debugger
   nil
end
when I poke around in the debugger the backtrace and $err variable just has a single line in it == to the message
Mitch VanDuyn
@catmando
Mar 19 2018 00:13
let me try building an example in try opal...
here ya go:
def funky_fact(x)
  if x.zero?
    one
  else
    x * funky_fact(x-1)
  end
end

def catch_a_fact(x)
  funky_fact(x)
rescue Exception => e
  puts e.backtrace
end

catch_a_fact(4)
prints ["one: undefined method 'one' for main"]
Jan Biedermann
@janbiedermann
Mar 19 2018 00:18
and in safari prints []
and in firefox [""]
Elia Schito
@elia
Mar 19 2018 09:38
@catmando can you open an issue? looks like a legit bug, or at best lack of proper documentation
Frederic ZINGG
@fzingg
Mar 19 2018 12:00
@fkchang I cannot manage to get OPAL_HOT_RELOADER working with SASS in my Rails App, any particular config ? Tx
Frederic ZINGG
@fzingg
Mar 19 2018 12:07

@fkchang I got it working but only if I use this declarative way in the application.scss:

 *= require_tree .
 *= require_self

If I use @import ... then it do not work.

Bernhard Weichel
@bwl21
Mar 19 2018 12:43

Today I dropped into a problem with Document.ready? In the following snippets foobar is undefined and its usage should raise an error:

Document.ready? do
  foobar
end

silently stops without any message on console etc. In order to handle problems I need to use the promise version

Document.ready.then do
  foobar
end.fail do
  alert "foobar failed"
end

Just for information: How could I catch problems in the non promise version?

Elia Schito
@elia
Mar 19 2018 13:15
@bwl21 the ready block is passed directly to $(…) in opal-jquery, errors should be handled like any other JS… which versions are you using?
Bernhard Weichel
@bwl21
Mar 19 2018 13:17
@elia: opal-jquery (0.4.2) via rubygems
Elia Schito
@elia
Mar 19 2018 13:17
opal?
Bernhard Weichel
@bwl21
Mar 19 2018 13:18
0.10.5
Bernhard Weichel
@bwl21
Mar 19 2018 13:23
I tracked it down, and found that in the ready? version it tries to fire the promise reject.
Bernhard Weichel
@bwl21
Mar 19 2018 14:51
I am starting to switch Zupfnoter to 0.11.0. After fixing some Syntactical warnings, I got it running. I feel it is about 10% faster.
For development, i am using Opal::Server. I had to add gem opal-sprockets to my gemfile and use Opal::Sprockets::Server instead of Opal::Server. Is there anything else with respect to Server I need to be aware of in upcoming version ? Will Opal::Sprockets::Server be there in the future? What about the role of Opal::SimpleServer?
Elia Schito
@elia
Mar 19 2018 14:53
Opal::Server was always based on sprockets, so it has been moved to the proper namespace, that said seemed good to have something in the core gem to spin up an opal server, so I put together Opal::SimpleServer
Bernhard Weichel
@bwl21
Mar 19 2018 17:15
I tried with Document.ready? and 0.11 it still silenty dies in case of errors.
Bernhard Weichel
@bwl21
Mar 19 2018 17:24
I still had to include opal-jquery from git. Would it be possible to get the gem updated via ruby-gems?