2
我移植這個JavaScript函數Scala.js:arguments.callee的在scala.js
once: function (el, type, callback) {
var typeArray = type.split(' ');
for (var i = typeArray.length - 1; i >= 0; i--) {
el.addEventListener(typeArray[i], function(e) {
e.target.removeEventListener(e.type, arguments.callee);
return callback(e);
});
};
},
這是我在寫的Scala代碼嘗試:
def once(element: TopNode, tpe: String, callback: Function1[Event,Any]): Unit = {
tpe.split(" ").foreach(item => element.addEventListener(item, (e : Event) => {
e.target.removeEventListener(e.`type`, ?) // <-- what do I put here?
callback(e)
}))
}
我如何可以參考我的拉姆達在那個地方持有人?