These are chat archives for opal/opal

26th
Aug 2015
Qqwy / Wiebe-Marten
@Qqwy
Aug 26 2015 15:37
@bwl21 : Yes. I have a main page which has two script tags in its head: the latest jquery version and application.js, which is the compiled result of the Opal Builder.
The problem I have right now still is that Opal's require does not work for non-(.rb, .opal or .js) files
Qqwy / Wiebe-Marten
@Qqwy
Aug 26 2015 15:43
require_tree 'app/views' throws errors, as it can see files like view.haml, item.haml but then tries to load files called view and item (without any extension)
also see opal/opal#1073
Nobody has responded to that issue yet
I hope someone will
Qqwy / Wiebe-Marten
@Qqwy
Aug 26 2015 20:52
All right!
I've released the simple boilerplate code I've made so far
it works, but it can still greatly be improved of course
any help, issues and questions are very welcome :-)
Qqwy / Wiebe-Marten
@Qqwy
Aug 26 2015 22:57

I'm having a very interesting problem with Node, by the way.
There's an object that Node makes that extends Node's EventEmitter. But I cannot figure out how to properly make the callbacks work with that
Is there a way to call methods on the native object directly?
Qqwy / Wiebe-Marten
@Qqwy
Aug 26 2015 23:05
A very simple example:
This is how EventEmitters work in Node:
    var EventEmitter = require('events').EventEmitter;
var radium = new EventEmitter();

radium.on('radiation', function(ray) {
    console.log(ray);
});

setInterval(function() {
    radium.emit('radiation', 'GAMMA');
}, 1000);    
This is what I tried with Opal:
`var EventEmitter = require('events').EventEmitter;`
radium = Native(`new EventEmitter()`);

radium.on('radiation')do |ray|
    console.log(ray);
end

`setInterval(function() {`
    radium.emit('radiation', 'GAMMA');
`}, 1000);`
The Opal code will never output anything on the console.