Skip to content

Commit 9ef16dc

Browse files
committed
[dist] v1.0.0
1 parent 9468c58 commit 9ef16dc

File tree

2 files changed

+27
-10
lines changed

2 files changed

+27
-10
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"author": "bradleymeck <bradley.meck@gmail.com>",
33
"name": "understudy",
44
"description": "action interceptor for dynamic extensible systems",
5-
"version": "0.1.1",
5+
"tags": ["buzzwords"],
6+
"version": "1.0.0",
67
"main": "lib/index.js",
78
"dependencies": {},
89
"devDependencies": {},

readme.md

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ A means to provide interceptors when performing actions.
44

55
## Design Considerations
66

7+
* Async
8+
9+
* * error first helpers
10+
11+
* * fail fast
12+
713
* Modify input not output from functions
814

915
* * modification of output can lead to a function giving odd results that do not match documentation
@@ -16,19 +22,22 @@ A means to provide interceptors when performing actions.
1622

1723
```
1824
var actor = new (require('understudy').Understudy)();
19-
actor.before('load:plugins', function (config, next) {
25+
function beforeHandler(config, next) {
2026
// load any plugins specified via config
21-
...
27+
// ...
2228
next();
23-
});
24-
actor.after('load:plugins', function (config, next) {
29+
}
30+
function afterHandler(config, next) {
2531
console.log('plugins have been loaded');
2632
next(config);
27-
});
28-
actor.perform('load:plugins', config, function (config, allowAfter) {
33+
}
34+
actor.before('load:plugins', beforeHandler);
35+
actor.after('load:plugins', afterHandler);
36+
actor.perform('load:plugins', config, function (err, config, allowAfter) {
2937
// start up app
30-
...
38+
// ...
3139
// opt-in for `after` interceptors
40+
actor.before.remove('load:plugins', beforeHandler);
3241
allowAfter();
3342
});
3443
```
@@ -39,6 +48,12 @@ actor.perform('load:plugins', config, function (config, allowAfter) {
3948

4049
`interceptor` - function to fire during action
4150

51+
### before.remove/after.remove(action, interceptor) arguments
52+
53+
`action` - name of the action
54+
55+
`interceptor` - function to remove from list of action handlers
56+
4257
### perform(action, ...args, done) arguments
4358

4459
`action` - name of the action
@@ -49,11 +64,12 @@ actor.perform('load:plugins', config, function (config, allowAfter) {
4964

5065
### action started
5166

52-
1. The actor will start performing an "action" with `...args` for arguments.
67+
1. The actor will start performing an "action" with `...args`.
5368
2. At the end of the arguments to the event will be added a `next` function.
69+
2. 1. The `next` function is used for passing state via arguments and accepts an error first argument in order to fail fast.
5470
3. Each before interceptors will be fired in order after the previous fires the `next` function.
5571
4. After all interceptors have been fired the `done` function will fire with the arguments passed to the next function and an opt-in function to allow after interceptors.
56-
5. If the `done` function opts in to after interceptors the after interceptors will be fired in order after the previous fires the `next` function.
72+
5. If the `done` function opts-in to after interceptors the after interceptors will be fired in order after the previous fires the `next` function.
5773

5874
## Examples
5975

0 commit comments

Comments
 (0)