Skip to content

Commit

Permalink
Merge pull request #11 from lexich/broadcast-option
Browse files Browse the repository at this point in the history
Broadcast option
  • Loading branch information
lexich committed Sep 25, 2015
2 parents d7af2ff + c3a4bfe commit 76c8011
Show file tree
Hide file tree
Showing 15 changed files with 783 additions and 440 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: node_js
node_js:
- '0.12'
- 'iojs'
- '4.0.0'
after_script:
- npm run coveralls
35 changes: 30 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import reduxApi, {transformers} from "redux-api";
> *default*: {}
> *example*:
Simple endpoint definition `GET /api/v1/entry` where response is Object
```js
```js
{
entry: "/api/v1/entry",
}
Expand Down Expand Up @@ -60,7 +60,7 @@ import reduxApi, {transformers} from "redux-api";
}
}
}
```
```
- @param **options.{endpoint}.url** - endpoint for rest api
> *type*: String
- @param **options.{endpoint}.transformer** - response transformer
Expand All @@ -82,7 +82,7 @@ import reduxApi, {transformers} from "redux-api";
> *type*: Object | Funtions
> *default*: null
> *example*: if you use [isomorphic-fetch](https://www.npmjs.com/package/isomorphic-fetch) backend
```js
```js
options: {
method: "post",
headers: {
Expand All @@ -100,8 +100,33 @@ import reduxApi, {transformers} from "redux-api";
}
};
}
```
```

- @param **options.{endpoint}.broadcast** - list of actions which would emit after data fetching.
> *type*: Array
> *default*: null
> *example*
```js
import {ACTION_ENTRY_UPDATE} from "./constants";
....
entry: {
url: "/api/v1/entry",
broadcast: [ ACTION_ENTRY_UPDATE ]
}
// in your redux reducer
function (state, action) {
switch (action.type) {
case ACTION_ENTRY_UPDATE:
return {
...state,
data: action.data // fetching data
};
default:
return state;
}
}
```


#### reduxApi object
`reduxApi` initializer returns non initialized object. You need to call `init` for initilize it.
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "redux-api",
"version": "0.3.0",
"version": "0.4.0",
"main": "dist/redux-api.min.js",
"dependencies": {}
}
Loading

0 comments on commit 76c8011

Please sign in to comment.