From fe41d7d94fd841540dfa700f167e49792de60798 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Wed, 24 Aug 2016 02:43:51 +0300 Subject: [PATCH] working on docs.. Signed-off-by: Alex A. Naanou --- README.md | 37 +++++++++++++++++++++++++++++++++++-- actions.js | 6 +++++- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0fa1fa7..c609d07 100644 --- a/README.md +++ b/README.md @@ -114,6 +114,7 @@ Now: - **Thread the return value down the call chain** The return value will get passed through all the actions in a chain before returning to the action caller. +- **Return `this` by default** - **Organise and apply actions to objects** - **Unified way to document actions** - **Introspection and inspection API** @@ -135,8 +136,11 @@ Now: - **Single return point** Only the _root_ action can return a value, any other returns by _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** +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 + Action event handler: o-------x o-------x diff --git a/actions.js b/actions.js index 0bd1d90..f8780e9 100755 --- a/actions.js +++ b/actions.js @@ -967,6 +967,8 @@ module.MetaActions = { // NOTE: if 'all' is set then mixin all the actions available, // otherwise only mixin local actions... // NOTE: this will override existing own attributes. + // + // XXX should we include functions by default???? inlineMixin: function(from, all, descriptors, all_attr_types){ // defaults... descriptors = descriptors || true @@ -1003,7 +1005,9 @@ module.MetaActions = { // actions and other attributes... } else { var attr = from[k] - if(all_attr_types || attr instanceof Action){ + if(all_attr_types + //|| attr instanceof Function + || attr instanceof Action){ that[k] = attr } }