cubekit-castle
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -7,2 +7,3 @@ 'use strict'; | ||
exports.fetch = fetch; | ||
exports.runMutation = runMutation; | ||
exports.clear = clear; | ||
@@ -93,2 +94,14 @@ exports.fetchStart = fetchStart; | ||
/** | ||
* Takes a migration, runs it, and applies its changes | ||
* when it has done. | ||
* | ||
* @param {Packages.Data.MutationBase} mutation | ||
* @param {Object} [params] | ||
*/ | ||
function runMutation(mutation, params) { | ||
return mutation.asAction(params); | ||
} | ||
/** | ||
* Clear all records for the given name in the app state. | ||
@@ -334,3 +347,3 @@ * | ||
* | ||
* @param {string} params | ||
* @param {Object} params | ||
* @param {string} params.name Name of the entity | ||
@@ -337,0 +350,0 @@ * @param {Object} params.data New values |
@@ -84,10 +84,10 @@ 'use strict'; | ||
case '@data/UPDATE': | ||
var content = state.content; | ||
var payload = action.payload; | ||
return (0, _reactAddonsUpdate2['default'])(state, { | ||
content: { | ||
$set: _lodash2['default'].map(state.content, function (data) { | ||
var idToUpdate = action.payload.id; | ||
var newValues = action.payload.data; | ||
return data.id == idToUpdate ? _extends({}, data, newValues) : data; | ||
}) | ||
$set: _lodash2['default'].isArray(content) ? _updateArrayContent(content, payload) : _updateObjectContent(content, payload) | ||
}, | ||
version: { $set: state.version + 1 } | ||
@@ -111,2 +111,16 @@ }); | ||
function _updateArrayContent(content, payload) { | ||
var idToUpdate = payload.id; | ||
var newValues = payload.data; | ||
return _lodash2['default'].map(content, function (data) { | ||
return data.id == idToUpdate ? _extends({}, data, newValues) : data; | ||
}); | ||
} | ||
function _updateObjectContent(content, payload) { | ||
var newValues = payload.data; | ||
return _lodash2['default'].merge({}, content, newValues); | ||
} | ||
function dataIndexReducer(state, action) { | ||
@@ -113,0 +127,0 @@ if (state === undefined) state = { |
{ | ||
"name": "cubekit-castle", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
117595
34
2548
1