monkjs
v0.1.0
Published
Create your class in javascript
Downloads
4
Maintainers
Readme
MonkJS
Getting started
bower install monkjs
How it works
Class
How to create a class
var Class = $Class({
attributes: {
name: ""
},
initialize: function(argument){
console.log('my new instance');
this.name = argument;
}
});
var instance1 = new Class('instance 1');
instance1.name; // => 'instance 1'
Class methods
Class extend method
Class.extendClass({
run: function(){
console.log('run method exec');
}
});
Class.run();
Include method: if you want to add a new method for all instances of the class
Class.include({
callName: function(){
console.log(this.name);
}
});
instance1.callName(); // => 'instance 1'
Singleton methods
Extend method
instance1.$extend({
type: 'instance'
});
instance1.type; // => 'instance'
Watch method
instance1.$watch('name', function(){
console.log('name has changed');
});
instance1.name = 'new name'; // => 'name has changed'
Unwatch method
instance1.$unwatch('name');
GetAttributes method
instance1.$getAttributes(); // => '[{"name": "instance 1"}]'
Decorator class
How use it
var TodoDecorator = $Decorator({
addTask: function(){
console.log('new task');
}
});
var TodoClass = TodoDecorator(Class);
var instance2 = new TodoClass();
instance2.addTask(); // => 'new task'
Policies functions
After method
Before method
List of functions
Extend method
Include method
Flip method
Contributing
- Fork it
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Added some feature')
- Push to the branch (git push origin my-new-feature)
- Create new Pull Request
Licence
MIT