Created
May 28, 2015 10:16
-
-
Save barneycarroll/d7e534f48f352bf2652d to your computer and use it in GitHub Desktop.
WiP: micro-config lifecycle for Mithril
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import m from 'mithril' | |
const rendered = [] | |
const tick = ( window.setImmediate || window.setTimeout ).bind( window, Function.prototype, 0 ) | |
const process = () => { | |
const couldunmounts = [] | |
const couldpostunmounts = [] | |
rendered.forEach( ( [ el, { ctrl, unmount, postunmount } ] ) => { | |
if( unmount ) unmounts.push( [ el, ctrl, unmount ] ) | |
if( postunmount ) unmounts.push( [ el, ctrl, postunmount ] ) | |
} ) | |
rendered.length = 0 | |
tick( () => { | |
const ctrls = new Map() | |
const unmounts = [] | |
const postunmounts = [] | |
const mounts = [] | |
const postmounts = [] | |
const renders = [] | |
const postrenders = [] | |
rendered.forEach( ( [ el, map ] ) => { | |
if( ctrls.has ) | |
} ) | |
} ) | |
} | |
m.mount( document.createElement( 'div' ), { | |
view : () => | |
m( 'div', { | |
config : () => | |
process | |
} ) | |
} ) | |
export default function on( node, map ){ | |
node.attrs.config = el => | |
rendered.push( el, map ) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment