redux-falcor
Advanced tools
@@ -276,3 +276,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
return promise.then(function (res) { | ||
next(_extends({}, rest, { res: res, type: SUCCESS })); | ||
next(_extends({}, rest, { cache: falcor.getCache(), type: SUCCESS })); | ||
return res; | ||
@@ -306,5 +306,5 @@ })['catch'](function (error) { | ||
var _deepmerge = __webpack_require__(4); | ||
var _falcorExpandCache = __webpack_require__(4); | ||
var _deepmerge2 = _interopRequireDefault(_deepmerge); | ||
var _falcorExpandCache2 = _interopRequireDefault(_falcorExpandCache); | ||
@@ -344,3 +344,3 @@ var _actions = __webpack_require__(1); | ||
if (endsWith(action.type, '_FAILURE') || action.type === _actions.RETRIEVE_VALUE) { | ||
if (endsWith(action.type, '_FAILURE')) { | ||
var requests = omit(_requests, action._id); | ||
@@ -351,2 +351,3 @@ return _extends({}, state, { loading: Object.keys(requests).length !== 0, _requests: requests }); | ||
switch (action.type) { | ||
case _actions.RETRIEVE_VALUE: | ||
case _actions.RETRIEVE_PATH: | ||
@@ -358,5 +359,5 @@ case _actions.RETRIEVE_PATHS: | ||
var requests = omit(_requests, action._id); | ||
var newState = _extends({}, state, { loading: Object.keys(requests).length !== 0, _requests: requests }); | ||
if (!action.res) return newState; | ||
return _deepmerge2['default'](newState, action.res.json); | ||
var newState = { loading: Object.keys(requests).length !== 0, _requests: requests }; | ||
if (!action.cache) return _extends({}, state, newState); | ||
return _extends({}, newState, _falcorExpandCache2['default'](action.cache)); | ||
@@ -375,58 +376,48 @@ case _actions.CLEAR: | ||
/* 4 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/***/ function(module, exports) { | ||
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;(function (root, factory) { | ||
if (true) { | ||
!(__WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); | ||
} else if (typeof exports === 'object') { | ||
module.exports = factory(); | ||
} else { | ||
root.deepmerge = factory(); | ||
} | ||
}(this, function () { | ||
'use strict'; | ||
return function deepmerge(target, src) { | ||
var array = Array.isArray(src); | ||
var dst = array && [] || {}; | ||
exports.__esModule = true; | ||
exports.default = expandCache; | ||
function expandCache(cache) { | ||
function followPath(path) { | ||
return path.reduce(function (acc, part) { | ||
if (acc && acc[part]) { | ||
return acc[part]; | ||
} | ||
if (array) { | ||
target = target || []; | ||
dst = dst.concat(target); | ||
src.forEach(function(e, i) { | ||
if (typeof dst[i] === 'undefined') { | ||
dst[i] = e; | ||
} else if (typeof e === 'object') { | ||
dst[i] = deepmerge(target[i], e); | ||
} else { | ||
if (target.indexOf(e) === -1) { | ||
dst.push(e); | ||
} | ||
} | ||
}); | ||
} else { | ||
if (target && typeof target === 'object') { | ||
Object.keys(target).forEach(function (key) { | ||
dst[key] = target[key]; | ||
}) | ||
return undefined; | ||
}, cache); | ||
} | ||
function expandChild(child) { | ||
if (child.$type === 'atom') return child.value; | ||
if (child.$type === 'ref') return createNode(followPath(child.value)); | ||
if (child.$type === 'error') return new Error(child.value); | ||
// Unknown Sentinel | ||
if (child.$type) return undefined; | ||
return createNode(child); | ||
} | ||
function createNode(data) { | ||
if (data.$type) return expandChild(data); | ||
var node = {}; | ||
Object.keys(data).forEach(function (key) { | ||
Object.defineProperty(node, key, { | ||
enumerable: true, | ||
get: function get() { | ||
return expandChild(data[key]); | ||
} | ||
Object.keys(src).forEach(function (key) { | ||
if (typeof src[key] !== 'object' || !src[key]) { | ||
dst[key] = src[key]; | ||
} | ||
else { | ||
if (!target[key]) { | ||
dst[key] = src[key]; | ||
} else { | ||
dst[key] = deepmerge(target[key], src[key]); | ||
} | ||
} | ||
}); | ||
} | ||
}); | ||
}); | ||
return dst; | ||
return node; | ||
} | ||
return createNode(cache); | ||
} | ||
})); | ||
/***/ }, | ||
@@ -433,0 +424,0 @@ /* 5 */ |
@@ -78,3 +78,3 @@ 'use strict'; | ||
return promise.then(function (res) { | ||
next(_extends({}, rest, { res: res, type: SUCCESS })); | ||
next(_extends({}, rest, { cache: falcor.getCache(), type: SUCCESS })); | ||
return res; | ||
@@ -81,0 +81,0 @@ })['catch'](function (error) { |
@@ -13,5 +13,5 @@ 'use strict'; | ||
var _deepmerge = require('deepmerge'); | ||
var _falcorExpandCache = require('falcor-expand-cache'); | ||
var _deepmerge2 = _interopRequireDefault(_deepmerge); | ||
var _falcorExpandCache2 = _interopRequireDefault(_falcorExpandCache); | ||
@@ -51,3 +51,3 @@ var _actions = require('./actions'); | ||
if (endsWith(action.type, '_FAILURE') || action.type === _actions.RETRIEVE_VALUE) { | ||
if (endsWith(action.type, '_FAILURE')) { | ||
var requests = omit(_requests, action._id); | ||
@@ -58,2 +58,3 @@ return _extends({}, state, { loading: Object.keys(requests).length !== 0, _requests: requests }); | ||
switch (action.type) { | ||
case _actions.RETRIEVE_VALUE: | ||
case _actions.RETRIEVE_PATH: | ||
@@ -65,5 +66,5 @@ case _actions.RETRIEVE_PATHS: | ||
var requests = omit(_requests, action._id); | ||
var newState = _extends({}, state, { loading: Object.keys(requests).length !== 0, _requests: requests }); | ||
if (!action.res) return newState; | ||
return _deepmerge2['default'](newState, action.res.json); | ||
var newState = { loading: Object.keys(requests).length !== 0, _requests: requests }; | ||
if (!action.cache) return _extends({}, state, newState); | ||
return _extends({}, newState, _falcorExpandCache2['default'](action.cache)); | ||
@@ -70,0 +71,0 @@ case _actions.CLEAR: |
{ | ||
"name": "redux-falcor", | ||
"version": "2.3.3", | ||
"version": "3.0.0-beta1", | ||
"description": "A helper library for integratig Redux & Falcor", | ||
@@ -37,2 +37,3 @@ "main": "lib/index.js", | ||
"deepmerge": "^0.2.10", | ||
"falcor-expand-cache": "^0.0.1", | ||
"falcor-json-graph": "^2.0.0", | ||
@@ -39,0 +40,0 @@ "tiny-uuid": "^1.0.0" |
@@ -71,3 +71,3 @@ import { | ||
.then(res => { | ||
next({ ...rest, res, type: SUCCESS }); | ||
next({ ...rest, cache: falcor.getCache(), type: SUCCESS }); | ||
return res; | ||
@@ -74,0 +74,0 @@ }) |
@@ -1,2 +0,2 @@ | ||
import merge from 'deepmerge'; | ||
import expandCache from 'falcor-expand-cache'; | ||
import { | ||
@@ -33,3 +33,3 @@ RETRIEVE_VALUE, | ||
if (endsWith(action.type, '_FAILURE') || action.type === RETRIEVE_VALUE) { | ||
if (endsWith(action.type, '_FAILURE')) { | ||
const requests = omit(_requests, action._id); | ||
@@ -40,2 +40,3 @@ return {...state, loading: Object.keys(requests).length !== 0, _requests: requests }; | ||
switch (action.type) { | ||
case RETRIEVE_VALUE: | ||
case RETRIEVE_PATH: | ||
@@ -47,5 +48,5 @@ case RETRIEVE_PATHS: | ||
const requests = omit(_requests, action._id); | ||
const newState = {...state, loading: Object.keys(requests).length !== 0, _requests: requests}; | ||
if (!action.res) return newState; | ||
return merge(newState, action.res.json); | ||
const newState = { loading: Object.keys(requests).length !== 0, _requests: requests }; | ||
if (!action.cache) return {...state, ...newState }; | ||
return { ...newState, ...(expandCache(action.cache)) }; | ||
@@ -52,0 +53,0 @@ case CLEAR: |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
273450
8.73%5
25%13
-48%813
-1.33%1
Infinity%