109
edits
(Created page with 'Raindrop == General Architecture == For a quick summary of Raindrop's complete architecture, see Raindrop Software Architecture. The Fro…') |
|||
| Line 144: | Line 144: | ||
<pre> | <pre> | ||
//Tell the loader the name of this | //Tell the loader that rdw/Message will be modified, | ||
//and give the name of this extension. Also indicate | |||
//the dependencies for the extension. | |||
run.modify("rdw/Message", "ext/sample", | |||
/ | ["rd", "rdw/Message"], function (rd, Message) { | ||
/ | |||
//Tell raindrop you want to apply an extension, and what will be extended. | //Tell raindrop you want to apply an extension, and what will be extended. | ||
rd.applyExtension("ext | rd.applyExtension("ext/sample", "rdw/Message", { | ||
//Register "before" extension points. | |||
//These extension functions should be called before | |||
//the matching function on rdw/Message | |||
before: { | |||
//This postCreate will be called before an instance of | |||
//rdw/Message's postCreate method is called. | |||
postCreate: function() { | |||
} | |||
}, | |||
//Register "after" extension points. | |||
//These extension functions should be called before | |||
//the matching function on rdw/Message | |||
after: { | |||
//This postCreate will be called after an instance of | |||
//rdw/Message's postCreate method is called. | |||
postCreate: function() { | |||
} | |||
}, | |||
//Register "around" extension points. | |||
//These extension functions should be called before | |||
//the matching function on rdw/Message, and this extension | |||
//point has the option to to call the original rdw/Message | |||
//function or bypass it completely. It also has the ability | |||
//to modify the return value from the rdw/Message function call. | |||
//This type of extension point is very experimental and may | |||
//change due to its use of arguments.callee | |||
around: { | |||
//This postCreate will be called before an instance of | |||
//rdw/Message's postCreate method is called. If it wants to | |||
//call rdw/Message's postCreate function, it can | |||
postCreate: function() { | |||
//Demonstrates calling the rdw/Message function | |||
//that this extension point is wrapping around. | |||
var value = arguments.callee.target.apply(this, arguments); | |||
//Modify value then return it. | |||
} | |||
}, | |||
//Register "replace" extension points. | |||
//These extension functions replace the the matching function | |||
//on rdw/Message. It will first check rdw/Message for | |||
//the matching function, then look at rdw/Message's prototype | |||
//for the method. | |||
replace: { | |||
//This postCreate will be replace rdw/Message's | |||
//prototype.postCreate | |||
postCreate: function() { | |||
} | |||
}, | |||
//Register "add" extension points. | |||
//These extension functions will be added to rdw/Message. | |||
//Note that they are added to rdw/Message, and *not* | |||
//rdw/Message's prototype, so they will not be callable | |||
//from instances of rdw/Message. | |||
add: { | |||
//This function will be placed on rdw/Message, | |||
//it is like adding a "class-level" | |||
//function vs an instance-level function. | |||
getInstances: function() { | |||
} | |||
}, | |||
//Register "addToPrototype" extension points. | |||
//These extension functions will be | |||
//added to rdw/Message's prototype, and *not* to rdw/Message. | |||
addToPrototype: { | |||
//This function will be placed on | |||
//rdw/Message's prototype, it is like adding an | |||
//instance-level function vs a "class-level" function. | |||
onActionClick: function() { | |||
} | |||
} | |||
}); | |||
}); | }); | ||
edits