Since ES6 classes need to be called with new and this needs to be an instance of the class, components will not work with a class. The issue stems from here: https://github.com/lhorie/mithril.js/blob/next/mithril.js#L554
Example (using babel-compiled class): https://jsfiddle.net/1prjtv78/
A work around is to wrap the component controller like:
var Component = {
controller: function () { return new ComponentController(...arguments); }.
view: View
};
Which transpiles to something equally ugly:
var _bind = Function.prototype.bind;
var Component = {
controller: function () { return new (_bind.apply(ComponentController, [null].concat(arguments)))(); }.
view: View
};
Example of working: https://jsfiddle.net/1prjtv78/1/
Perhaps the parametize.controller function can do something similar to the transpiled code.
Since ES6 classes need to be called with
newandthisneeds to be an instance of the class, components will not work with a class. The issue stems from here: https://github.com/lhorie/mithril.js/blob/next/mithril.js#L554Example (using babel-compiled class): https://jsfiddle.net/1prjtv78/
A work around is to wrap the component controller like:
Which transpiles to something equally ugly:
Example of working: https://jsfiddle.net/1prjtv78/1/
Perhaps the
parametize.controllerfunction can do something similar to the transpiled code.