redux-fluent
Advanced tools
Comparing version 0.8.4 to 0.8.5
@@ -5,2 +5,16 @@ # Change Log | ||
## [0.8.5](https://github.com/Code-Y/redux-fluent/compare/v0.8.4...v0.8.5) (2019-03-10) | ||
### Bug Fixes | ||
* **typings:** add action.error field ([11aace0](https://github.com/Code-Y/redux-fluent/commit/11aace0)) | ||
### Reverts | ||
* don't include action.error if no payload ([523d069](https://github.com/Code-Y/redux-fluent/commit/523d069)) | ||
## [0.8.4](https://github.com/Code-Y/redux-fluent/compare/v0.8.3...v0.8.4) (2019-03-10) | ||
@@ -7,0 +21,0 @@ |
/**! | ||
* @build-info development - Sun Mar 10 2019 16:55:58 GMT+0000 (Coordinated Universal Time) | ||
* @build-info development - Sun Mar 10 2019 17:31:01 GMT+0000 (Coordinated Universal Time) | ||
* @name redux-fluent | ||
* @version 0.8.4 | ||
* @version 0.8.5 | ||
* @author Code-Y | ||
@@ -160,5 +160,5 @@ * @description Enjoy Redux - Less Boilerplate / Go Functional | ||
type: type, | ||
error: payload instanceof Error, | ||
}; | ||
if (payload !== undefined) { | ||
res.error = payload instanceof Error; | ||
res.payload = payload; | ||
@@ -165,0 +165,0 @@ } |
/**! | ||
* @build-info production - Sun Mar 10 2019 16:55:58 GMT+0000 (Coordinated Universal Time) | ||
* @build-info production - Sun Mar 10 2019 17:31:01 GMT+0000 (Coordinated Universal Time) | ||
* @name redux-fluent | ||
* @version 0.8.4 | ||
* @version 0.8.5 | ||
* @author Code-Y | ||
@@ -17,3 +17,3 @@ * @description Enjoy Redux - Less Boilerplate / Go Functional | ||
**/ | ||
module.exports=function(e){var n={};function t(r){if(n[r])return n[r].exports;var u=n[r]={i:r,l:!1,exports:{}};return e[r].call(u.exports,u,u.exports,t),u.l=!0,u.exports}return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:r})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var u in e)t.d(r,u,function(n){return e[n]}.bind(null,u));return r},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="",t(t.s=1)}([function(e,n){e.exports=require("redux")},function(e,n,t){e.exports=t(2)},function(e,n,t){"use strict";t.r(n);var r=t(0),u=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return e.reduce(function(e,n){var t;return Object.assign({},e,((t={})[n.type]=n,t))},{})},o=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return Object(r.combineReducers)(u.apply(void 0,e))};function i(e,n,t){var r=n||function(e){return e},u=t||function(e,n){return n};function o(n,t){var o=r(n,t,e),i=u(n,t,e),c={type:e,error:o instanceof Error};return void 0!==o&&(c.payload=o),void 0!==i&&(c.meta=i),Object.freeze(c)}return Object.defineProperties(o,{name:{configurable:!0,value:"action('"+e+"')"},toString:{value:function(){return e}},type:{enumerable:!0,value:e}}),o}var c=function(){return{config:void 0,getDefaultState:void 0,handlers:[]}};function f(e){var n=c(),t=function(e,t,r){return void 0===e?n.getDefaultState(void 0,t,r):e};function r(e,r){return n.handlers.reduce(function(e,t){return t(e,r,n.config)},t(e,r,n.config))}return Object.defineProperties(r,{$$context:{value:n},name:{configurable:!0,value:"reducer('"+e+"')"},type:{enumerable:!0,value:e}}),{actions:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n.handlers=e,{default:function(e){return void 0===e&&(e=function(){return null}),n.getDefaultState=e,r}}}}}var a=function(e){for(var n=[],t=1;t<arguments.length;t++)n[t-1]=arguments[t];var r=[e].concat(n).map(function(e){return e.type||e.toString()});return{map:function(e){return function(n,t,u){return r.includes(t.type)?e(n,t,u):n}}}},l=function(e){return function(n){var t,r=n.$$context,u=(t=f(n.type)).actions.apply(t,r.handlers).default(r.getDefaultState);return u.$$context.config=Object.assign({},r.config||{},e),Object.defineProperty(u,"name",{configurable:!0,value:"withConfig("+n.name+")"}),u}};t.d(n,"combineReducers",function(){return o}),t.d(n,"createReducersMapObject",function(){return u}),t.d(n,"createAction",function(){return i}),t.d(n,"createReducer",function(){return f}),t.d(n,"ofType",function(){return a}),t.d(n,"withConfig",function(){return l})}]); | ||
module.exports=function(e){var n={};function t(r){if(n[r])return n[r].exports;var u=n[r]={i:r,l:!1,exports:{}};return e[r].call(u.exports,u,u.exports,t),u.l=!0,u.exports}return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:r})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var u in e)t.d(r,u,function(n){return e[n]}.bind(null,u));return r},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="",t(t.s=1)}([function(e,n){e.exports=require("redux")},function(e,n,t){e.exports=t(2)},function(e,n,t){"use strict";t.r(n);var r=t(0),u=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return e.reduce(function(e,n){var t;return Object.assign({},e,((t={})[n.type]=n,t))},{})},o=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return Object(r.combineReducers)(u.apply(void 0,e))};function i(e,n,t){var r=n||function(e){return e},u=t||function(e,n){return n};function o(n,t){var o=r(n,t,e),i=u(n,t,e),c={type:e};return void 0!==o&&(c.error=o instanceof Error,c.payload=o),void 0!==i&&(c.meta=i),Object.freeze(c)}return Object.defineProperties(o,{name:{configurable:!0,value:"action('"+e+"')"},toString:{value:function(){return e}},type:{enumerable:!0,value:e}}),o}var c=function(){return{config:void 0,getDefaultState:void 0,handlers:[]}};function f(e){var n=c(),t=function(e,t,r){return void 0===e?n.getDefaultState(void 0,t,r):e};function r(e,r){return n.handlers.reduce(function(e,t){return t(e,r,n.config)},t(e,r,n.config))}return Object.defineProperties(r,{$$context:{value:n},name:{configurable:!0,value:"reducer('"+e+"')"},type:{enumerable:!0,value:e}}),{actions:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n.handlers=e,{default:function(e){return void 0===e&&(e=function(){return null}),n.getDefaultState=e,r}}}}}var a=function(e){for(var n=[],t=1;t<arguments.length;t++)n[t-1]=arguments[t];var r=[e].concat(n).map(function(e){return e.type||e.toString()});return{map:function(e){return function(n,t,u){return r.includes(t.type)?e(n,t,u):n}}}},l=function(e){return function(n){var t,r=n.$$context,u=(t=f(n.type)).actions.apply(t,r.handlers).default(r.getDefaultState);return u.$$context.config=Object.assign({},r.config||{},e),Object.defineProperty(u,"name",{configurable:!0,value:"withConfig("+n.name+")"}),u}};t.d(n,"combineReducers",function(){return o}),t.d(n,"createReducersMapObject",function(){return u}),t.d(n,"createAction",function(){return i}),t.d(n,"createReducer",function(){return f}),t.d(n,"ofType",function(){return a}),t.d(n,"withConfig",function(){return l})}]); | ||
//# sourceMappingURL=redux-fluent.production.js.map |
{ | ||
"name": "redux-fluent", | ||
"license": "MIT", | ||
"version": "0.8.4", | ||
"version": "0.8.5", | ||
"homepage": "https://github.com/Code-Y/redux-fluent#readme", | ||
@@ -6,0 +6,0 @@ "description": "Enjoy Redux - Less Boilerplate / Go Functional", |
@@ -20,10 +20,10 @@ # <a href='https://github.com/Code-Y/redux-fluent'><img src='https://raw.githubusercontent.com/Code-Y/redux-fluent/master/redux-fluent-logo.png' height='60' alt='Redux Fluent' aria-label='https://github.com/Code-Y/redux-fluent' /></a> redux-fluent | ||
- **λ Go Functional**, Everything is a function and reducers are built by function composition rather than piling up if and switch-case statements: [*Let's introduce Redux Fluent Reducers*](#createreducer). | ||
- **Reducers at scale**, due to being handling multiple actions, reducers tend to grow and become difficult to maintain: [*Let's introduce Redux Fluent Action Handlers*](#oftype). | ||
- **Less boilerplate**, Flux architecture is usually verbose and some of their concepts, such as `Action`, `Action Type` and `Action Creator` could all be implemented in a single entity: [*Let's introduce Redux Fluent Actions*](#createaction). | ||
- **FSA compliance**, FSA Actions may have a `error: boolean` field, which indicates whether the action represents a failure or not. Respecting this pattern leads to a series of if statements inside reducers, compromising both readability and maintainability, so the community normally tends to split error and failures into two separate actions (eg: `ADD_TODO_SUCCESS` and `ADD_TODO_ERROR`) which reduces cognitive complexity on one hand but produces even more boilerplate on the other. *Let's embrace FSA and abstract error handling with filterable action handlers*. | ||
- **λ Go Functional**, Everything is a function and reducers are built by function composition rather than piling up if and switch-case statements: [*Let's introduce Redux Fluent Reducers*](#createreducer). | ||
- **Reducers at scale**, due to being handling multiple actions, reducers tend to grow and become difficult to maintain: [*Let's introduce Redux Fluent Action Handlers*](#oftype). | ||
- **Less boilerplate**, Flux architecture is usually verbose and some of their concepts, such as `Action`, `Action Type` and `Action Creator` could all be implemented in a single entity: [*Let's introduce Redux Fluent Actions*](#createaction). | ||
- **FSA compliance**, FSA Actions may have a `error: boolean` field, which indicates whether the action represents a failure or not. Respecting this pattern leads to a series of if statements inside reducers, compromising both readability and maintainability, so the community normally tends to split error and failures into two separate actions (eg: `ADD_TODO_SUCCESS` and `ADD_TODO_ERROR`) which reduces cognitive complexity on one hand but produces even more boilerplate on the other. *Let's embrace FSA and abstract error handling with filterable action handlers*. | ||
## Installation | ||
```bash | ||
``` | ||
yarn add redux-fluent redux | ||
@@ -39,3 +39,2 @@ ``` | ||
export const addTodo = createAction('todos | add'); | ||
console.log(addTodo.type); // 'todos | add' | ||
``` | ||
@@ -75,8 +74,8 @@ | ||
- [`createReducer()`](#createreducer) | ||
- [`createAction()`](#createaction) | ||
- [`ofType()`](#oftype) | ||
- [`withConfig()`](#withconfig) | ||
- [`combineReducers()`](#combinereducers) | ||
- [`createReducersMapObject()`](#createreducersmapobject) | ||
- [`createReducer()`](#createreducer) | ||
- [`createAction()`](#createaction) | ||
- [`ofType()`](#oftype) | ||
- [`withConfig()`](#withconfig) | ||
- [`combineReducers()`](#combinereducers) | ||
- [`createReducersMapObject()`](#createreducersmapobject) | ||
@@ -106,3 +105,3 @@ ### `createReducer()` | ||
const action = createAction( | ||
createAction( | ||
type: string, | ||
@@ -113,3 +112,5 @@ payloadCreator?: (rawPayload, rawMeta, type) => payload, | ||
console.log(action.type); | ||
const addTodo = createAction('todos | add'); | ||
console.log(addTodo.type); // 'todos | add' | ||
console.log(addTodo({ id: 1, title: 'have a break' })); // { type: 'todos | add', payload: { id: 1, title: 'have a break' } } | ||
``` | ||
@@ -116,0 +117,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
70679
191