storeon-observable
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -5,4 +5,9 @@ # Change Log | ||
## 0.2.0 | ||
- **typings:** Add type definition (#2)[https://github.com/distolma/storeon-observable/issues/2] ((26d46a2)[https://github.com/distolma/storeon-observable/commit/26d46a2]) | ||
## 0.1.0 | ||
- Move Rxjs to the peerDependencies. | ||
## 0.0.1 | ||
- Initial release. |
@@ -0,0 +0,0 @@ var operators = require('rxjs/operators') |
{ | ||
"name": "storeon-observable", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "RxJS based module for Storeon which allows to create async actions", | ||
@@ -13,3 +13,3 @@ "main": "index.js", | ||
"lint": "eslint *.js", | ||
"test": "yarn lint && size-limit" | ||
"test": "jest --coverage && yarn lint && size-limit" | ||
}, | ||
@@ -16,0 +16,0 @@ "peerDependencies": { |
@@ -17,3 +17,3 @@ # Storeon Observable | ||
## Install | ||
This module has peer dependencie of `rxjs@6.x.x` which will has to be installed as well. | ||
```sh | ||
@@ -25,5 +25,5 @@ npm install storeon-observable | ||
Create simple epic using RxJS operators. | ||
You need to create epic using RxJS operators. This epic will listen to event `ping`, wait for 1 second and map them to a new event, `pong` | ||
#### `epics.js` | ||
#### `epic.js` | ||
```javascript | ||
@@ -42,3 +42,3 @@ import { combineEpics, ofEvent } from 'storeon-observable'; | ||
Connect all epics to the Storeon using the `storeon-observable` middleware | ||
Create store and pass `epics` to the `createEpicMiddleware` function. It will connect all epics to the Storeon using the `storeon-observable` middleware | ||
@@ -59,2 +59,30 @@ #### `store.js` | ||
export const store = createStore([increment, createEpicMiddleware(epics)]); | ||
``` | ||
``` | ||
Using TypeScript you can assign `Epic` interface to the function to specify `action` and `state` typing | ||
#### `epic.ts` | ||
```typescript | ||
import { combineEpics, ofEvent, Epic } from 'storeon-observable'; | ||
import { mapTo, delay } from 'rxjs/operators' | ||
interface State { | ||
isPinging: boolean; | ||
} | ||
const epic: Epic<State> = (action$, state$) => action$.pipe( | ||
ofEvent('ping'), | ||
delay(1000), | ||
mapTo('pong'), | ||
); | ||
export const epics = combineEpics([epic]); | ||
``` | ||
## Acknowledgments | ||
This module based on [redux-observable](https://github.com/redux-observable/redux-observable). | ||
## License | ||
[MIT](LICENCE) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7285
45
84
6