mirror of
https://github.com/flynx/features.js.git
synced 2025-10-29 18:30:11 +00:00
working on docs..
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
7195daa116
commit
fe41d7d94f
37
README.md
37
README.md
@ -114,6 +114,7 @@ Now:
|
|||||||
- **Thread the return value down the call chain**
|
- **Thread the return value down the call chain**
|
||||||
The return value will get passed through all the actions in a chain
|
The return value will get passed through all the actions in a chain
|
||||||
before returning to the action caller.
|
before returning to the action caller.
|
||||||
|
- **Return `this` by default**
|
||||||
- **Organise and apply actions to objects**
|
- **Organise and apply actions to objects**
|
||||||
- **Unified way to document actions**
|
- **Unified way to document actions**
|
||||||
- **Introspection and inspection API**
|
- **Introspection and inspection API**
|
||||||
@ -135,8 +136,11 @@ Now:
|
|||||||
- **Single return point**
|
- **Single return point**
|
||||||
Only the _root_ action can return a value, any other returns by
|
Only the _root_ action can return a value, any other returns by
|
||||||
_extending_ actions are ignored
|
_extending_ actions are ignored
|
||||||
- **Return `this` by default**
|
- **No state transferred via mixin**
|
||||||
|
The only two things _inherited_ from the object defining the actions
|
||||||
|
via the mixin methods or `mix` function are properties and actions,
|
||||||
|
all data, including normal methods is discarded.
|
||||||
|
_(this is not final)_
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -155,6 +159,35 @@ Now:
|
|||||||
|
|
||||||
**Action**
|
**Action**
|
||||||
|
|
||||||
|
A full example:
|
||||||
|
```javascript
|
||||||
|
// ...
|
||||||
|
|
||||||
|
minimal: [function(){
|
||||||
|
// ...
|
||||||
|
}],
|
||||||
|
|
||||||
|
full: ['Short info string',
|
||||||
|
'Long documentation string, describing the action',
|
||||||
|
function(){
|
||||||
|
// pre code
|
||||||
|
// run before the parent action...
|
||||||
|
|
||||||
|
return function(res){
|
||||||
|
// post code
|
||||||
|
// run after the parent action or directly after
|
||||||
|
// the pre-code of this is the root action...
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
|
||||||
|
// ...
|
||||||
|
```
|
||||||
|
|
||||||
|
Both documentation strings and the return callback are optional.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
The call diagram:
|
||||||
```
|
```
|
||||||
+ pre + pre + + post + post +
|
+ pre + pre + + post + post +
|
||||||
Action event handler: o-------x o-------x
|
Action event handler: o-------x o-------x
|
||||||
|
|||||||
@ -967,6 +967,8 @@ module.MetaActions = {
|
|||||||
// NOTE: if 'all' is set then mixin all the actions available,
|
// NOTE: if 'all' is set then mixin all the actions available,
|
||||||
// otherwise only mixin local actions...
|
// otherwise only mixin local actions...
|
||||||
// NOTE: this will override existing own attributes.
|
// NOTE: this will override existing own attributes.
|
||||||
|
//
|
||||||
|
// XXX should we include functions by default????
|
||||||
inlineMixin: function(from, all, descriptors, all_attr_types){
|
inlineMixin: function(from, all, descriptors, all_attr_types){
|
||||||
// defaults...
|
// defaults...
|
||||||
descriptors = descriptors || true
|
descriptors = descriptors || true
|
||||||
@ -1003,7 +1005,9 @@ module.MetaActions = {
|
|||||||
// actions and other attributes...
|
// actions and other attributes...
|
||||||
} else {
|
} else {
|
||||||
var attr = from[k]
|
var attr = from[k]
|
||||||
if(all_attr_types || attr instanceof Action){
|
if(all_attr_types
|
||||||
|
//|| attr instanceof Function
|
||||||
|
|| attr instanceof Action){
|
||||||
that[k] = attr
|
that[k] = attr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user