Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/trakkasure/extendable.js
https://github.com/trakkasure/extendable.js
Last synced: 16 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/trakkasure/extendable.js
- Owner: Trakkasure
- License: mit
- Created: 2014-01-29T06:24:34.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2014-03-31T17:20:50.000Z (almost 11 years ago)
- Last Synced: 2024-04-15T22:17:13.505Z (9 months ago)
- Language: JavaScript
- Size: 207 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Extendable.js
=============Extendable.js is a simple library for heirarchical development.
It was developed so that people who are comfortable with development
methodologies used in Java can use similar capabilities in JavaScript.Minimum requirement is that the javascript processor supports ES5.
Simple example:
```javascript
function myBaseClass() {
this['super'](); // Call super constructor. Here, that would be Extendable.
// do some stuff.
}myBaseClass.prototype.method1 = function() {
// do some stuff in this method in the BaseClass.
}myBaseClass.prototype.coreMethod = function() {
// just a core method that subclass probably won't override.
}Extendable.extend(myBaseClass); // myBaseClass is a subclass of Extendable. This is how it starts.
function mySubClass() {
this['super'](); // Call super constructor. Here, that would be myBaseClass.
// do some stuff.
}mySubClass.prototype.method1 = function() {
// do some stuff in the subclass' version of base method.this['super'].method1(); // call the parent class' version of method1.
// do more stuff....
this.coreMethod(); // This will call the parent class coreMethod
// since it doesn't exist on the current class.
// It is inherrited.
}myBaseClass.extend(mySubClass);
```Additional features
===================Creating a hook to execute whenever a subclass extends this class or any descendant class.
```javascript
myBaseClass.extendHook = function() {
// do some stuff to handle when any subclass extends this class.
}mySubClass.extendHook = function() {
// do some stuff to handle extending
}```
In the above code, when mySubClass extends myBaseClass, the myBaseClass extend hook is called
at the point ``` myBaseClass.extend(mySubClass); ``` is called.