Functor Mithril drastically simplifies Mithril's component API surface. A component now consists of a function, executed on initialisation, which returns another, which is executed every loop, and whose return value is virtual DOM. Both functions receive the first argument supplied via hyperscript, and a function which will execute post draw loop and is supplied with the underlying DOM.
function setup(initialInput, setup){
setup(dom => {
dom.style.opacity = 0
dom.style.transition = '1s'
void dom.clientHeight
dom.style.opacity = 1
})
return function view(input, postDraw){
return m('p', 'Hi')
}
}
Follow the link above to see a component, written in Functor Mithril which handles setup and async DOM teardown!