Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
tnhu committed Jan 9, 2011
1 parent 692116c commit d0f2dc5
Showing 1 changed file with 35 additions and 53 deletions.
88 changes: 35 additions & 53 deletions README.md
Expand Up @@ -103,6 +103,41 @@ A sub-class is defined by specifying its parent class in $meta.
}
});

### Multiple inheritance

A sub class can inherit API from multiple parents.

jsface.def({
$meta: {
name: 'Options'
},

setOptions: function(attrs){
jsface.bindProperties(this, attrs);
}
});

jsface.def({
$meta: {
name: 'Events'
},

bind: function(eventName, fn){
}
});

jsface.def({
$meta: {
name: 'Foo',
parent: [ Options, Events ]
},

Foo: function(opts) {
this.setOptions(opts);
this.bind("click", jsface.noop);
}
});

### Static methods

Static methods are class level methods which you can invoke from both class or class instances. jsFace
Expand Down Expand Up @@ -309,59 +344,6 @@ If you want to skip method executing, return false in before(). For example:
foo.say === undefined;
foo.after === undefined;

### Plugins

A class can inherit APIs from other classes via $meta.plugins (shortcut of jsface.plugins). A class can
extend from only one parent class but it can inherit multiple classes.

jsface.def({
$meta: {
name: 'Options'
},

setOptions: function(attrs){
jsface.bindProperties(this, attrs);
}
});

jsface.def({
$meta: {
name: 'Foo',
plugins: Options
},

Foo: function(opts) {
this.setOptions(opts);
}
});

var foo = new Foo({ name : "Rika", age: 24 });
foo.name === "Rika";
foo.age === 24;

Multiple plugins:

jsface.def({
$meta: {
name: 'Events'
},

bind: function(eventName, fn){
}
});

jsface.def({
$meta: {
name: 'Foo',
plugins: [ Options, Events ]
},

Foo: function(opts) {
this.setOptions(opts);
this.bind("click", jsface.noop);
}
});

### Profiling

jsFace gives you the ability to profile your class/instance via jsface.profiling(). All
Expand Down

0 comments on commit d0f2dc5

Please sign in to comment.