Skip to content

Instantly share code, notes, and snippets.

@HendrikRoth
Last active August 29, 2015 14:21
Show Gist options
  • Save HendrikRoth/c43a8ec3264e85c9d8cc to your computer and use it in GitHub Desktop.
Save HendrikRoth/c43a8ec3264e85c9d8cc to your computer and use it in GitHub Desktop.
'use strict'
function createView(ctrl, opts, children) {
return m('h1', 'Cached')
}
function controller() {
return {
view: m.prop()
}
}
function view(ctrl, opts, children) {
var view = ctrl.view()
if (!view || opts.refresh) {
view = createView(ctrl, opts, children)
ctrl.view(view)
return view
}
return {subtree: 'retain'}
}
module.exports = {
controller: controller,
view: view
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment