I have this code that I would like to be able to execute as Javascript :
@JSExport
class Feeder {
@JSExport
def feed(feedable: Feedable): Unit = {
feedable.feed();
}
}
trait Feedable {
def feed()
}
Of course traits cannot be exported, but I expected that a kind of pattern matching was enough. So I tried to create a Javascript object with a feed
function but It fail too :
var feeder = new test.Feeder();
var feedable = new function() {
this.feed = function() {
console.log('Feeding javascript');
}
}
feeder.feed(feedable);
But that raise an exception :
scala.scalajs.runtime.UndefinedBehaviorError: An undefined behavior was detected: [object Object] is not an instance of test.Feedable
Is it a way to achieve this behavior ?