Editing JavaScript/Notes/Factory
Jump to navigation
Jump to search
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 300: | Line 300: | ||
=== Solution I: A Decorator Factory Factory That Takes a Constructor === | === Solution I: A Decorator Factory Factory That Takes a Constructor === | ||
Decorator Factory Factory takes a constructor that takes an element id as its first argument and any number of | Decorator Factory Factory takes a constructor and returns a Decorator Factory that takes an element id as its first argument and any number of arguments thereafter. | ||
<source lang="javascript"> | <source lang="javascript"> | ||
// Create a factory. | // Create a factory. | ||
var ElementWrapperFactory = makeFactory(function() { | var ElementWrapperFactory = makeFactory(function() { | ||
function ElementWrapper (id, x, y) { | function ElementWrapper (id, x, y) { | ||
this.id = id; | this.id = id; |