Skip to content

Commit

Permalink
now requires promise in props
Browse files Browse the repository at this point in the history
  • Loading branch information
capaj committed Dec 28, 2015
1 parent 373289a commit c775d21
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
19 changes: 15 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,20 @@ const ExampleWithAsync = (props) => <Async promise={prom} then={(val) => {return
Much simpler, especially if your component is read-only, like the example.
## install
With jspm:
```
jspm i npm:react-async
```
or with npm:
```
npm i react-async
```
## [Available props](https://github.com/capaj/react-async/blob/master/async.js#L48):
- *promise* a promise you want to wait for
- *then* runs when promise is resolved. Async will run function provided in it's render passing a resolved value as first parameter.
- *catch* runs when promise is rejected. Async will run function provided in it's render passing an error as first parameter.
- *pendingRender*(optional) is a node which will be outputted from Async render method while promise is pending. If none is provided, defaults to `<div/>`
- **promise** a promise you want to wait for
- **then**(optional) runs when promise is resolved. Async will run function provided in it's render passing a resolved value as first parameter.
- **catch**(optional) runs when promise is rejected. Async will run function provided in it's render passing an error as first parameter.
- **pendingRender**(optional) is a node which will be outputted from Async render method while promise is pending. If none is provided, defaults to `<div/>`
2 changes: 1 addition & 1 deletion async.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Async.propTypes = {
then: PropTypes.func,
catch: PropTypes.func,
pendingRender: PropTypes.node,
promise: PropTypes.object
promise: PropTypes.object.isRequired
}

export default Async
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-async",
"version": "1.0.1",
"version": "1.0.2",
"description": "react.js component",
"main": "async.js",
"scripts": {
Expand Down

0 comments on commit c775d21

Please sign in to comment.