These are chat archives for opal/opal

24th
Aug 2015
Suchipi
@suchipi
Aug 24 2015 06:35
Does anyone know of some good documentation on Opal.modules ?
I'm not sure if I need to keep track of if things have already been loaded or if I can leave that to Opal
Forrest Chang
@fkchang
Aug 24 2015 17:17
@Qqwy maybe my guard for opal-rails might be handy for some ideas/examples http://funkworks.blogspot.com/2015/03/guard-opal-rails-gems-released.html?q=guard
@elia I'm up for an awesome opal, it seems like the meta ruby resources that @AstonJ setup is basically the start of such
Qqwy / Wiebe-Marten
@Qqwy
Aug 24 2015 20:19
Thanks a lot, @fkchang !
I'm having steady progress with my attempt to integrate Opal with nwjs
What I am getting stumped at a little right now however, is the fact that I am trying to use opal-haml. However, it seems that the inner workings of the Opal require function has recently changed, since it does not recognize any non-.rb file anymore, when passed without an explicit extension
e.g. require 'app/views/test.html.haml' works
but require 'app/views/test' does not
As a result, require_tree 'app/views' doesn't work either, and that mass-require behavior is actually what I want to use to include the user-generated views in Opal.
meh.
@meh
Aug 24 2015 20:22
Qqwy, looks like a bug caused by my recent changes
Qqwy / Wiebe-Marten
@Qqwy
Aug 24 2015 20:25
Is there a way to easily revert this behaviour?
meh.
@meh
Aug 24 2015 20:25
Qqwy, no
Qqwy / Wiebe-Marten
@Qqwy
Aug 24 2015 20:25
And should I create an issue on GitHub for it?
meh.
@meh
Aug 24 2015 20:25
Qqwy, probably
I'm not sure it's a bug, or caused by my changes, but do open an issue
if it worked before it's likely a regression
Qqwy / Wiebe-Marten
@Qqwy
Aug 24 2015 20:31
It at least goes against what is stated here: https://github.com/opal/opal-haml
I think this is where it happens
meh.
@meh
Aug 24 2015 20:35
Qqwy, I didn't change the regex used there
so it's either a regression or a documentation bug :P
never touched opal-haml so dunno
Qqwy / Wiebe-Marten
@Qqwy
Aug 24 2015 20:36
;-)
No problem! Thank you for your help
Qqwy / Wiebe-Marten
@Qqwy
Aug 24 2015 21:34
I have another question: I'm trying to pass an Opal block as callback of a JS function.

In this case, using the Node request library, I'm trying:
var request = require("request")
request(#{url},
yield
)

Obviously this is not working. But I am looking to do something similar

meh.
@meh
Aug 24 2015 21:36
I'm not sure I understand what you want to do from that code
Qqwy / Wiebe-Marten
@Qqwy
Aug 24 2015 21:38

Ah, let me explain.

The npm request package allows you to get content from a remote URL (without relying on AJAX). It is usually used as follows:

request('http://example.com', function(error, response, body){ / Do something with the result here /})
Where body will contain the body of the HTTP response, response contains the headers and other metadata and error is empty unless there was a problem, in which case it is an array, iirc.
Basically I want to grab the results (that are gathered asynchroniously as everything is -for better or worse- in Node, and call a Ruby block with it
meh.
@meh
Aug 24 2015 21:43
well
a Ruby block is just a JS function
Qqwy / Wiebe-Marten
@Qqwy
Aug 24 2015 21:44
Wait, so I can just pass it's name inside a #{} ?
meh.
@meh
Aug 24 2015 21:45
yeah
Qqwy / Wiebe-Marten
@Qqwy
Aug 24 2015 21:45
like do_something_with_passed_function(#{ruby_block_name}) ?
Wow, awesome!
meh.
@meh
Aug 24 2015 21:45
yeah
Qqwy / Wiebe-Marten
@Qqwy
Aug 24 2015 21:45
It works! :D
meh.
@meh
Aug 24 2015 21:45
if you want the parameters to be wrapped in a native
you can use Native.proc { } instead of proc { }
Qqwy / Wiebe-Marten
@Qqwy
Aug 24 2015 21:52
Is there documentation on the proper use of Native somewhere?
meh.
@meh
Aug 24 2015 21:53
I don't think so
but the code is really small and self-contained
Qqwy / Wiebe-Marten
@Qqwy
Aug 24 2015 22:09
Where can I find the source code for Native?
meh.
@meh
Aug 24 2015 22:11
Qqwy, stdlib