redux-observable
Advanced tools
Comparing version 0.7.2 to 0.8.0
@@ -0,1 +1,12 @@ | ||
<a name="0.8.0"></a> | ||
# [0.8.0](https://github.com/redux-observable/redux-observable/compare/v0.7.2...v0.8.0) (2016-07-24) | ||
### Features | ||
* **replaceEpic:** Added middleware method to replace the root Epic. Useful for code splitting and hot reloading ([a8f458d](https://github.com/redux-observable/redux-observable/commit/a8f458d)) | ||
* **replaceEpic:** Dispatches an EPIC_END action when you replaceEpic() ([#75](https://github.com/redux-observable/redux-observable/issues/75)) ([fef6f80](https://github.com/redux-observable/redux-observable/commit/fef6f80)) | ||
<a name="0.7.2"></a> | ||
@@ -2,0 +13,0 @@ ## [0.7.2](https://github.com/redux-observable/redux-observable/compare/v0.7.1...v0.7.2) (2016-07-14) |
@@ -9,4 +9,4 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
else | ||
root["ReduxObservable"] = factory(root["Rx"], root["Rx"]["Observable"], root["Rx"]["Observable"]["prototype"]); | ||
})(this, function(__WEBPACK_EXTERNAL_MODULE_2__, __WEBPACK_EXTERNAL_MODULE_3__, __WEBPACK_EXTERNAL_MODULE_6__) { | ||
root["ReduxObservable"] = factory(root["Rx"], root["Rx"]["Observable"]["prototype"], root["Rx"]["Observable"]); | ||
})(this, function(__WEBPACK_EXTERNAL_MODULE_1__, __WEBPACK_EXTERNAL_MODULE_4__, __WEBPACK_EXTERNAL_MODULE_5__) { | ||
return /******/ (function(modules) { // webpackBootstrap | ||
@@ -64,3 +64,3 @@ /******/ // The module cache | ||
var _createEpicMiddleware = __webpack_require__(5); | ||
var _createEpicMiddleware = __webpack_require__(7); | ||
@@ -74,3 +74,3 @@ Object.defineProperty(exports, 'createEpicMiddleware', { | ||
var _ActionsObservable = __webpack_require__(1); | ||
var _ActionsObservable = __webpack_require__(2); | ||
@@ -84,3 +84,3 @@ Object.defineProperty(exports, 'ActionsObservable', { | ||
var _combineEpics = __webpack_require__(4); | ||
var _combineEpics = __webpack_require__(6); | ||
@@ -94,4 +94,19 @@ Object.defineProperty(exports, 'combineEpics', { | ||
var _EPIC_END = __webpack_require__(3); | ||
Object.defineProperty(exports, 'EPIC_END', { | ||
enumerable: true, | ||
get: function get() { | ||
return _EPIC_END.EPIC_END; | ||
} | ||
}); | ||
/***/ }, | ||
/* 1 */ | ||
/***/ function(module, exports) { | ||
module.exports = __WEBPACK_EXTERNAL_MODULE_1__; | ||
/***/ }, | ||
/* 2 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
@@ -108,5 +123,5 @@ | ||
var _Observable2 = __webpack_require__(2); | ||
var _Observable2 = __webpack_require__(1); | ||
var _filter = __webpack_require__(6); | ||
var _filter = __webpack_require__(4); | ||
@@ -167,15 +182,26 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
/***/ }, | ||
/* 2 */ | ||
/* 3 */ | ||
/***/ function(module, exports) { | ||
module.exports = __WEBPACK_EXTERNAL_MODULE_2__; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var EPIC_END = exports.EPIC_END = '@@redux-observable/EPIC_END'; | ||
/***/ }, | ||
/* 3 */ | ||
/* 4 */ | ||
/***/ function(module, exports) { | ||
module.exports = __WEBPACK_EXTERNAL_MODULE_3__; | ||
module.exports = __WEBPACK_EXTERNAL_MODULE_4__; | ||
/***/ }, | ||
/* 4 */ | ||
/* 5 */ | ||
/***/ function(module, exports) { | ||
module.exports = __WEBPACK_EXTERNAL_MODULE_5__; | ||
/***/ }, | ||
/* 6 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
@@ -190,3 +216,3 @@ | ||
var _merge = __webpack_require__(3); | ||
var _merge = __webpack_require__(5); | ||
@@ -211,3 +237,3 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
/***/ }, | ||
/* 5 */ | ||
/* 7 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
@@ -222,17 +248,30 @@ | ||
var _Subject = __webpack_require__(2); | ||
var _Subject = __webpack_require__(1); | ||
var _from = __webpack_require__(3); | ||
var _BehaviorSubject = __webpack_require__(1); | ||
var _ActionsObservable = __webpack_require__(1); | ||
var _from = __webpack_require__(5); | ||
var _switchMap = __webpack_require__(4); | ||
var _ActionsObservable = __webpack_require__(2); | ||
var _EPIC_END = __webpack_require__(3); | ||
function createEpicMiddleware(epic) { | ||
var actions = new _Subject.Subject(); | ||
var actionsObs = new _ActionsObservable.ActionsObservable(actions); | ||
var actionsSubject = new _Subject.Subject(); | ||
var action$ = new _ActionsObservable.ActionsObservable(actionsSubject); | ||
var epic$ = new _BehaviorSubject.BehaviorSubject(epic); | ||
var store = void 0; | ||
var middleware = function middleware(store) { | ||
var epicMiddleware = function epicMiddleware(_store) { | ||
store = _store; | ||
return function (next) { | ||
if (epic) { | ||
epic(actionsObs, store).subscribe(store.dispatch); | ||
if (typeof epic === 'function') { | ||
_switchMap.switchMap.call(epic$, function (epic) { | ||
return epic(action$, store); | ||
}).subscribe(store.dispatch); | ||
} | ||
return function (action) { | ||
@@ -244,8 +283,7 @@ if (typeof action === 'function') { | ||
var obs = (0, _from.from)(action(actionsObs, store)); | ||
var sub = obs.subscribe(store.dispatch); | ||
return sub; | ||
var out$ = (0, _from.from)(action(action$, store)); | ||
return out$.subscribe(store.dispatch); | ||
} else { | ||
var result = next(action); | ||
actions.next(action); | ||
actionsSubject.next(action); | ||
return result; | ||
@@ -257,11 +295,10 @@ } | ||
return middleware; | ||
epicMiddleware.replaceEpic = function (epic) { | ||
store.dispatch({ type: _EPIC_END.EPIC_END }); | ||
epic$.next(epic); | ||
}; | ||
return epicMiddleware; | ||
} | ||
/***/ }, | ||
/* 6 */ | ||
/***/ function(module, exports) { | ||
module.exports = __WEBPACK_EXTERNAL_MODULE_6__; | ||
/***/ } | ||
@@ -268,0 +305,0 @@ /******/ ]) |
@@ -1,1 +0,1 @@ | ||
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r(require(void 0),require(void 0),require(void 0)):"function"==typeof define&&define.amd?define([,,],r):"object"==typeof exports?exports.ReduxObservable=r(require(void 0),require(void 0),require(void 0)):e.ReduxObservable=r(e.Rx,e.Rx.Observable,e.Rx.Observable.prototype)}(this,function(e,r,t){return function(e){function r(n){if(t[n])return t[n].exports;var o=t[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,r),o.loaded=!0,o.exports}var t={};return r.m=e,r.c=t,r.p="",r(0)}([function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t(5);Object.defineProperty(r,"createEpicMiddleware",{enumerable:!0,get:function(){return n.createEpicMiddleware}});var o=t(1);Object.defineProperty(r,"ActionsObservable",{enumerable:!0,get:function(){return o.ActionsObservable}});var i=t(4);Object.defineProperty(r,"combineEpics",{enumerable:!0,get:function(){return i.combineEpics}})},function(e,r,t){"use strict";function n(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function o(e,r){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!r||"object"!=typeof r&&"function"!=typeof r?e:r}function i(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function, not "+typeof r);e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),r&&(Object.setPrototypeOf?Object.setPrototypeOf(e,r):e.__proto__=r)}Object.defineProperty(r,"__esModule",{value:!0}),r.ActionsObservable=void 0;var u=function(){function e(e,r){for(var t=0;r.length>t;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(r,t,n){return t&&e(r.prototype,t),n&&e(r,n),r}}(),c=t(2),a=t(6);r.ActionsObservable=function(e){function r(e){n(this,r);var t=o(this,Object.getPrototypeOf(r).call(this));return t.source=e,t}return i(r,e),u(r,[{key:"lift",value:function(e){var t=new r(this);return t.operator=e,t}},{key:"ofType",value:function(){for(var e=arguments.length,r=Array(e),t=0;e>t;t++)r[t]=arguments[t];return a.filter.call(this,function(e){var t=e.type,n=r.length;if(1===n)return t===r[0];for(var o=0;n>o;o++)if(r[o]===t)return!0;return!1})}}]),r}(c.Observable)},function(r,t){r.exports=e},function(e,t){e.exports=r},function(e,r,t){"use strict";function n(e){if(Array.isArray(e)){for(var r=0,t=Array(e.length);e.length>r;r++)t[r]=e[r];return t}return Array.from(e)}Object.defineProperty(r,"__esModule",{value:!0}),r.combineEpics=void 0;var o=t(3);r.combineEpics=function(){for(var e=arguments.length,r=Array(e),t=0;e>t;t++)r[t]=arguments[t];return function(e,t){return o.merge.apply(void 0,n(r.map(function(r){return r(e,t)})))}}},function(e,r,t){"use strict";function n(e){var r=new o.Subject,t=new u.ActionsObservable(r),n=function(n){return function(o){return e&&e(t,n).subscribe(n.dispatch),function(e){if("function"==typeof e){"undefined"!=typeof console&&void 0!==console.warn&&console.warn('DEPRECATION: Using thunkservables with redux-observable is now deprecated in favor of the new "Epics" feature. See http://redux-observable.js.org/docs/FAQ.html#why-were-thunkservables-deprecated');var u=(0,i.from)(e(t,n)),c=u.subscribe(n.dispatch);return c}var a=o(e);return r.next(e),a}}};return n}Object.defineProperty(r,"__esModule",{value:!0}),r.createEpicMiddleware=n;var o=t(2),i=t(3),u=t(1)},function(e,r){e.exports=t}])}); | ||
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r(require(void 0),require(void 0),require(void 0)):"function"==typeof define&&define.amd?define([,,],r):"object"==typeof exports?exports.ReduxObservable=r(require(void 0),require(void 0),require(void 0)):e.ReduxObservable=r(e.Rx,e.Rx.Observable.prototype,e.Rx.Observable)}(this,function(e,r,t){return function(e){function r(n){if(t[n])return t[n].exports;var o=t[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,r),o.loaded=!0,o.exports}var t={};return r.m=e,r.c=t,r.p="",r(0)}([function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t(7);Object.defineProperty(r,"createEpicMiddleware",{enumerable:!0,get:function(){return n.createEpicMiddleware}});var o=t(2);Object.defineProperty(r,"ActionsObservable",{enumerable:!0,get:function(){return o.ActionsObservable}});var i=t(6);Object.defineProperty(r,"combineEpics",{enumerable:!0,get:function(){return i.combineEpics}});var u=t(3);Object.defineProperty(r,"EPIC_END",{enumerable:!0,get:function(){return u.EPIC_END}})},function(r,t){r.exports=e},function(e,r,t){"use strict";function n(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function o(e,r){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!r||"object"!=typeof r&&"function"!=typeof r?e:r}function i(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function, not "+typeof r);e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),r&&(Object.setPrototypeOf?Object.setPrototypeOf(e,r):e.__proto__=r)}Object.defineProperty(r,"__esModule",{value:!0}),r.ActionsObservable=void 0;var u=function(){function e(e,r){for(var t=0;r.length>t;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(r,t,n){return t&&e(r.prototype,t),n&&e(r,n),r}}(),c=t(1),a=t(4);r.ActionsObservable=function(e){function r(e){n(this,r);var t=o(this,Object.getPrototypeOf(r).call(this));return t.source=e,t}return i(r,e),u(r,[{key:"lift",value:function(e){var t=new r(this);return t.operator=e,t}},{key:"ofType",value:function(){for(var e=arguments.length,r=Array(e),t=0;e>t;t++)r[t]=arguments[t];return a.filter.call(this,function(e){var t=e.type,n=r.length;if(1===n)return t===r[0];for(var o=0;n>o;o++)if(r[o]===t)return!0;return!1})}}]),r}(c.Observable)},function(e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});r.EPIC_END="@@redux-observable/EPIC_END"},function(e,t){e.exports=r},function(e,r){e.exports=t},function(e,r,t){"use strict";function n(e){if(Array.isArray(e)){for(var r=0,t=Array(e.length);e.length>r;r++)t[r]=e[r];return t}return Array.from(e)}Object.defineProperty(r,"__esModule",{value:!0}),r.combineEpics=void 0;var o=t(5);r.combineEpics=function(){for(var e=arguments.length,r=Array(e),t=0;e>t;t++)r[t]=arguments[t];return function(e,t){return o.merge.apply(void 0,n(r.map(function(r){return r(e,t)})))}}},function(e,r,t){"use strict";function n(e){var r=new o.Subject,t=new a.ActionsObservable(r),n=new i.BehaviorSubject(e),s=void 0,l=function(o){return s=o,function(o){return"function"==typeof e&&c.switchMap.call(n,function(e){return e(t,s)}).subscribe(s.dispatch),function(e){if("function"==typeof e){"undefined"!=typeof console&&void 0!==console.warn&&console.warn('DEPRECATION: Using thunkservables with redux-observable is now deprecated in favor of the new "Epics" feature. See http://redux-observable.js.org/docs/FAQ.html#why-were-thunkservables-deprecated');var n=(0,u.from)(e(t,s));return n.subscribe(s.dispatch)}var i=o(e);return r.next(e),i}}};return l.replaceEpic=function(e){s.dispatch({type:f.EPIC_END}),n.next(e)},l}Object.defineProperty(r,"__esModule",{value:!0}),r.createEpicMiddleware=n;var o=t(1),i=t(1),u=t(5),c=t(4),a=t(2),f=t(3)}])}); |
@@ -15,4 +15,8 @@ import { Middleware, MiddlewareAPI, Action } from 'redux'; | ||
export declare function createEpicMiddleware(rootEpic: Epic): Middleware; | ||
export interface EpicMiddleware extends Middleware { | ||
replaceEpic(nextEpic: Epic): void; | ||
} | ||
export declare function createEpicMiddleware(rootEpic: Epic): EpicMiddleware; | ||
export declare function combineEpics(...epics: Epic[]): Epic; |
@@ -10,15 +10,28 @@ 'use strict'; | ||
var _BehaviorSubject = require('rxjs/BehaviorSubject'); | ||
var _from = require('rxjs/observable/from'); | ||
var _switchMap = require('rxjs/operator/switchMap'); | ||
var _ActionsObservable = require('./ActionsObservable'); | ||
var _EPIC_END = require('./EPIC_END'); | ||
function createEpicMiddleware(epic) { | ||
var actions = new _Subject.Subject(); | ||
var actionsObs = new _ActionsObservable.ActionsObservable(actions); | ||
var actionsSubject = new _Subject.Subject(); | ||
var action$ = new _ActionsObservable.ActionsObservable(actionsSubject); | ||
var epic$ = new _BehaviorSubject.BehaviorSubject(epic); | ||
var store = void 0; | ||
var middleware = function middleware(store) { | ||
var epicMiddleware = function epicMiddleware(_store) { | ||
store = _store; | ||
return function (next) { | ||
if (epic) { | ||
epic(actionsObs, store).subscribe(store.dispatch); | ||
if (typeof epic === 'function') { | ||
_switchMap.switchMap.call(epic$, function (epic) { | ||
return epic(action$, store); | ||
}).subscribe(store.dispatch); | ||
} | ||
return function (action) { | ||
@@ -30,8 +43,7 @@ if (typeof action === 'function') { | ||
var obs = (0, _from.from)(action(actionsObs, store)); | ||
var sub = obs.subscribe(store.dispatch); | ||
return sub; | ||
var out$ = (0, _from.from)(action(action$, store)); | ||
return out$.subscribe(store.dispatch); | ||
} else { | ||
var result = next(action); | ||
actions.next(action); | ||
actionsSubject.next(action); | ||
return result; | ||
@@ -43,3 +55,8 @@ } | ||
return middleware; | ||
epicMiddleware.replaceEpic = function (epic) { | ||
store.dispatch({ type: _EPIC_END.EPIC_END }); | ||
epic$.next(epic); | ||
}; | ||
return epicMiddleware; | ||
} |
@@ -32,2 +32,11 @@ 'use strict'; | ||
} | ||
}); | ||
var _EPIC_END = require('./EPIC_END'); | ||
Object.defineProperty(exports, 'EPIC_END', { | ||
enumerable: true, | ||
get: function get() { | ||
return _EPIC_END.EPIC_END; | ||
} | ||
}); |
{ | ||
"name": "redux-observable", | ||
"version": "0.7.2", | ||
"version": "0.8.0", | ||
"description": "RxJS based middleware for Redux. Compose and cancel async actions and more.", | ||
@@ -80,7 +80,12 @@ "main": "lib/index.js", | ||
"cross-env": "^1.0.8", | ||
"eslint": "^2.10.2", | ||
"eslint": "^3.1.1", | ||
"gitbook-cli": "^0.3.4", | ||
"gitbook-plugin-addcssjs": "1.0.2", | ||
"gitbook-plugin-anker-enable": "0.0.3", | ||
"gitbook-plugin-edit-link": "2.0.2", | ||
"gitbook-plugin-github": "2.0.0", | ||
"gitbook-plugin-prism": "1.0.0", | ||
"gitbook-plugin-theme-default": "1.0.4", | ||
"json-server": "^0.8.14", | ||
"mocha": "^2.4.5", | ||
"promise": "^7.1.1", | ||
"redux": "^3.5.1", | ||
@@ -87,0 +92,0 @@ "rimraf": "^2.5.2", |
<img title="logo" src="logo/logo-small.gif" width="16.5%"> | ||
<img title="redux-observable" src="logo/logo-text-small.png" width="72%"> | ||
[![Join the chat at https://gitter.im/redux-observable/redux-observable](https://badges.gitter.im/redux-observable/redux-observable.svg)](https://gitter.im/redux-observable/redux-observable?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) | ||
[![build status](https://img.shields.io/travis/reactjs/redux/master.svg)](https://travis-ci.org/redux-observable/redux-observable) | ||
[![npm version](https://img.shields.io/npm/v/redux-observable.svg)](https://www.npmjs.com/package/redux) | ||
[![npm downloads](https://img.shields.io/npm/dm/redux-observable.svg)](https://www.npmjs.com/package/redux) | ||
[![npm version](https://img.shields.io/npm/v/redux-observable.svg)](https://www.npmjs.com/package/redux-observable) | ||
[![npm downloads](https://img.shields.io/npm/dm/redux-observable.svg)](https://www.npmjs.com/package/redux-observable) | ||
[![code climate](https://codeclimate.com/github/redux-observable/redux-observable/badges/gpa.svg)](https://codeclimate.com/github/redux-observable/redux-observable) | ||
[RxJS 5](http://github.com/ReactiveX/RxJS)-based middleware for | ||
[Redux](http://github.com/reactjs/redux). Compose and cancel async actions and more. | ||
[Redux](http://github.com/reactjs/redux). Compose and cancel async actions to create side effects and more. | ||
@@ -21,2 +22,12 @@ ## Install | ||
## JSBin Examples | ||
To see redux-observable in action, here's a very simple JSBin to play around with: | ||
* [Using Raw HTML APIs](http://jsbin.com/vayoho/edit?js,output) | ||
* [Using React](http://jsbin.com/jexomi/edit?js,output) | ||
* [Using Angular v1](http://jsbin.com/laviti/edit?js,output) | ||
* Using Angular v2 (TODO) | ||
* Using Ember (TODO) | ||
## Documentation | ||
@@ -28,9 +39,20 @@ | ||
* [Recipes](docs/recipes/SUMMARY.md) | ||
* [Writing Tests](docs/recipes/WritingTests.md) | ||
* [Cancellation](docs/recipes/Cancellation.md) | ||
* [Error Handling](docs/recipes/ErrorHandling.md) | ||
* [Writing Tests](docs/recipes/WritingTests.md) | ||
* [Usage with UI Frameworks](docs/recipes/UsageWithUIFrameworks.md) | ||
* [FAQ](docs/FAQ.md) | ||
* [Troubleshooting](docs/Troubleshooting.md) | ||
* [API Reference](docs/api/SUMMARY.md) | ||
* [createEpicMiddleware](docs/api/createEpicMiddleware.md) | ||
* [combineEpics](docs/api/combineEpics.md) | ||
* [EpicMiddleware](docs/api/EpicMiddleware.md) | ||
* [CHANGELOG](CHANGELOG.md) | ||
## Discuss | ||
[![Join the chat at https://gitter.im/redux-observable/redux-observable](https://badges.gitter.im/redux-observable/redux-observable.svg)](https://gitter.im/redux-observable/redux-observable?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) | ||
Everyone is welcome on our [Gitter channel](https://gitter.im/redux-observable/redux-observable?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)! | ||
:shipit: |
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
32092
12
390
57
30