File tree 4 files changed +63
-0
lines changed
4 files changed +63
-0
lines changed Original file line number Diff line number Diff line change
1
+ {
2
+ "presets" : [" es2015" ]
3
+ }
Original file line number Diff line number Diff line change @@ -31,3 +31,5 @@ node_modules
31
31
32
32
# Optional REPL history
33
33
.node_repl_history
34
+
35
+ /lib
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " redux-observable-middleware" ,
3
+ "version" : " 0.0.0" ,
4
+ "description" : " " ,
5
+ "main" : " ./lib/index.js" ,
6
+ "files" : [
7
+ " lib" ,
8
+ " src"
9
+ ],
10
+ "repository" : {
11
+ "type" : " git" ,
12
+ "url" : " git+https://github.com/d6u/redux-observable-middleware.git"
13
+ },
14
+ "author" :
" Daiwei Lu <[email protected] > (http://daiwei.lu)" ,
15
+ "license" : " MIT" ,
16
+ "bugs" : {
17
+ "url" : " https://github.com/d6u/redux-observable-middleware/issues"
18
+ },
19
+ "homepage" : " https://github.com/d6u/redux-observable-middleware#readme" ,
20
+ "dependencies" : {},
21
+ "devDependencies" : {
22
+ "babel-cli" : " ^6.5.1" ,
23
+ "babel-core" : " ^6.5.2" ,
24
+ "babel-preset-es2015" : " ^6.5.0" ,
25
+ "rimraf" : " ^2.5.2"
26
+ },
27
+ "scripts" : {
28
+ "clean" : " rimraf lib" ,
29
+ "build:lib" : " babel src --out-dir lib" ,
30
+ "build" : " npm run build:lib" ,
31
+ "preversion" : " npm run check" ,
32
+ "postversion" : " git push && git push --tags" ,
33
+ "prepublish" : " npm run clean && npm run build"
34
+ }
35
+ }
Original file line number Diff line number Diff line change
1
+ function observableMiddleware ( { dispatch, getState } ) {
2
+ return ( next ) => ( action ) => {
3
+ if ( action . observable != null &&
4
+ typeof action . observable . subscribe === 'function' )
5
+ {
6
+ observable . subscribe (
7
+ function onNext ( data ) {
8
+ dispatch ( { type : `${ action . type } _ON_NEXT` , data } ) ;
9
+ } ,
10
+ function onError ( err ) {
11
+ dispatch ( { type : `${ action . type } _ON_ERROR` , err } ) ;
12
+ } ,
13
+ function onCompleted ( ) {
14
+ dispatch ( { type : `${ action . type } _ON_COMPLETED` } ) ;
15
+ }
16
+ ) ;
17
+ }
18
+
19
+ next ( action ) ;
20
+ }
21
+ }
22
+
23
+ module . exports = observableMiddleware ;
You can’t perform that action at this time.
0 commit comments