0.0.0 • Published 10 years ago
bloody-functionhook v0.0.0
function hook
install
$ npm install bloody-functionhook
require
var hook = require("bloody-functionhook")
api
hook(object, propertyName) > notifier
replaces object[propertyName]
by the hook function, and returns a notifier
.
notifier
notifier.on(event, cb)
"arguments"
fires when the arguments are accessible to the hook function"error"
fires if an error occurred"call"
fires when the function is called"return"
fires when the function has a result
notifier.count
(int)
the times the function was called
notifier.emit("destroy")
removes the hook
example
var view = cornea.extend({
getInitialData : function(){
return {
foo : ""
}
},
template : function(data){
return "<div></div>"
}
})
var notifier = hook(view, "template")
var data = {
foo : "bar"
}
notifier.on("arguments", function(args){
test.equal(args[0], data, "data is passed")
test.end()
})
view.update(data)
0.0.0
10 years ago