Skip to content

ds.class

digital synapse edited this page Mar 3, 2015 · 2 revisions

ds.class

ds.class( options )
ds.static.class( options )

This function accepts an object that will be used to construct the class.

###Options

  • type <string> (optional)
    used to name the class/namespace. If omitted, no type or namespace will be created. This is useful if you want to use dependency injection or some other means rather than namespacing to control access to the class.

  • constructor <function> (optional)
    this is the optional constructor function.

  • inherits <object|array> (optional)
    specifies classes that should be inherited.

  • implements <object|array> (optional)
    specifies interfaces that should be enforced.

  • public <object> (optional)
    specifies public properties for the object. This is useful for initializing public properties to default values. Also, unlike public properties created with this.*, members in the public object can be inherited.

  • private <object> (optional)
    specifies private properties for the object. This is useful for initializing private properties to default values. These properties are not enumerable and will not be serialized.

###Returns

  • The class object

###Example Class var Logger = ds.class({ constructor: function(useConsole){ this.useConsole=useConsole; }, log: function(str){ if (this.useConsole) console.log(str); } });

var write = new Logger(true);
write.log('Hello ds.oop!');

###Example Static Class var Logger = ds.static.class({ log: function(str){ console.log(str); } }); Logger.log('Hello ds.oop!');

For more information on ds.class check out the Getting Started Guide or the Tutorial

Back to Home

Clone this wiki locally