Skip to content

Instantly share code, notes, and snippets.

@gilbert
Last active August 29, 2015 14:18
Show Gist options
  • Save gilbert/0291304f829f6e40d398 to your computer and use it in GitHub Desktop.
Save gilbert/0291304f829f6e40d398 to your computer and use it in GitHub Desktop.
Mithril.js Extensions
m.deferred.resolve = function (value) {
var deferred = m.deferred()
deferred.resolve(value)
return deferred.promise
}
m.deferred.reject = function (value) {
var deferred = m.deferred()
deferred.reject(value)
return deferred.promise
}
m.withValue = function (callback) {
return m.withAttr('value', callback)
}
m.initComponent = function (component, options, content) {
var controller = new component.controller(options)
controller.render = function () {
return component.view(controller, options, content)
}
return controller
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment