Skip to content

Commit

Permalink
update changelog and readme;
Browse files Browse the repository at this point in the history
  • Loading branch information
switer committed Dec 27, 2013
1 parent fe594f5 commit df2646e
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 7 deletions.
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
## ChangeLog for: chainjs

## Version 0.0.2 - 2013/12/27

- [Feature]: add filter() api
- [Feature]: addstop() api

## Version 0.0.1 - 2013/12/25

- Pop step handler use cursor index instead of handlers.shift
- Implemence AOP: before api
- [Normal]: Pop step handler use cursor index instead of handlers.shift
- [Feature]: Implemence AOP: before() api
35 changes: 33 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,23 @@ Start the chain and invoke start handler
Chain(func).then(func1).then(func2).start();
```

### start()
Start the chain and invoke start handler
```javascript
Chain(func).then(func1).then(func2).start();
```

### stop()
Stop the chain, mark the chain as ending and destroy local variable
__notice:__after use chain.stop(), the chain contiue execute current step handler,
so use with return for stoping current step excution
```javascript
Chain(func).then(function (chain) {
chain.stop();
return;
}).start();
```

### next(nextParams)
Go to next step
```javascript
Expand Down Expand Up @@ -83,8 +100,7 @@ var chainData = chain.data();
```

### before(beforeHandler)

Will be invoked before each step
Will be invoked before each step in sync
```javascript
Chain(function (chain) {chain.next();})
.then(function (chain) { // Step 1
Expand All @@ -98,6 +114,21 @@ Chain(function (chain) {chain.next();})
.start();
```

### filter(filterHandler)
Invoked before `before` and `step` handler, it run before each chain step, you should use filter.next()
continue execute next filter or execute current step handler. If use filter.chain in filter,
the chain will skip current step handler and go to next step handler
```javascript
Chain(func, param)
.then(func)
.filter(function (filter) {
console.log('run filter');
setTimeout( function() {
filter.next();
});
});
```

## Testing

```bash
Expand Down
2 changes: 1 addition & 1 deletion build/chain.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ if (typeof exports !== 'undefined') {
}
exports.Chain = Chain;
} else {
root.Chain = Chain;
this.Chain = Chain;
}

});
2 changes: 1 addition & 1 deletion chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,5 +276,5 @@ if (typeof exports !== 'undefined') {
}
exports.Chain = Chain;
} else {
root.Chain = Chain;
this.Chain = Chain;
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chainjs",
"version": "0.0.1",
"version": "0.0.2",
"description": "Use chaining call to resolve the problem of javascript async callback handle ",
"main": "chain.js",
"scripts": {
Expand Down

0 comments on commit df2646e

Please sign in to comment.