react-context-api-store
Advanced tools
Comparing version 1.0.12 to 1.0.13
@@ -61,5 +61,5 @@ 'use strict'; | ||
return wantedState ? wantedState(_extends({}, storeState)) : {}; | ||
}, _this.mapActionsToProps = function (updateState, storeState) { | ||
}, _this.mapActionsToProps = function (updateStore, storeState) { | ||
return wantedMutators ? Object.keys(wantedMutators).reduce(function (accumulatedMutators, mutator) { | ||
return _extends({}, accumulatedMutators, _defineProperty({}, mutator, _this.dispatcher(updateState, storeState, wantedMutators[mutator]))); | ||
return _extends({}, accumulatedMutators, _defineProperty({}, mutator, _this.dispatcher(updateStore, storeState, wantedMutators[mutator]))); | ||
}, {}) : {}; | ||
@@ -71,3 +71,3 @@ }, _this.render = function () { | ||
function (context) { | ||
return _react2.default.createElement(WrappedComponent, _extends({}, _this.mapStateToProps(context.state), _this.mapActionsToProps(context.updateState, context.state), _this.props)); | ||
return _react2.default.createElement(WrappedComponent, _extends({}, _this.mapStateToProps(context.state), _this.mapActionsToProps(context.updateStore, context.state), _this.props)); | ||
} | ||
@@ -97,11 +97,12 @@ ); | ||
return _ret2 = (_temp2 = (_this2 = _possibleConstructorReturn(this, (_ref2 = Provider.__proto__ || Object.getPrototypeOf(Provider)).call.apply(_ref2, [this].concat(args))), _this2), _this2.state = _extends({}, _this2.props.store), _this2.persisted = false, _this2.updateState = function (updatedState) { | ||
var newState = _extends({}, _this2.state, updatedState); | ||
_this2.setState(newState); | ||
return _ret2 = (_temp2 = (_this2 = _possibleConstructorReturn(this, (_ref2 = Provider.__proto__ || Object.getPrototypeOf(Provider)).call.apply(_ref2, [this].concat(args))), _this2), _this2.state = _extends({}, _this2.props.store), _this2.persisted = false, _this2.persist = function () { | ||
if (_this2.props.persist !== false) { | ||
_this2.props.persist.storage.removeItem(_this2.props.persist.key || 'react-context-api-store'); | ||
_this2.props.persist.storage.setItem(_this2.props.persist.key || 'react-context-api-store', JSON.stringify(newState)); | ||
_this2.props.persist.storage.setItem(_this2.props.persist.key || 'react-context-api-store', JSON.stringify(_this2.state)); | ||
} | ||
}, _this2.updateStore = function (updatedStore, callback) { | ||
_this2.setState(_extends({}, _this2.state, updatedStore), function () { | ||
_this2.persist(); | ||
if (callback) callback(_this2.state); | ||
}); | ||
}, _this2.render = function () { | ||
@@ -112,3 +113,5 @@ return _react2.default.createElement( | ||
state: _extends({}, _this2.state), | ||
updateState: _this2.updateState | ||
updateStore: function updateStore(updatedStore, callback) { | ||
_this2.updateStore(updatedStore, callback); | ||
} | ||
} }, | ||
@@ -127,3 +130,3 @@ _this2.props.children | ||
this.updateState(savedStore ? this.props.persist.statesToPersist(JSON.parse(savedStore)) : {}); | ||
this.updateStore(savedStore ? this.props.persist.statesToPersist(JSON.parse(savedStore)) : {}); | ||
} | ||
@@ -130,0 +133,0 @@ } |
{ | ||
"name": "react-context-api-store", | ||
"version": "1.0.12", | ||
"description": "An HOC state management inpired by redux implemented using react's context api.", | ||
"version": "1.0.13", | ||
"description": "Seemless, lightweight, state management library that supports async actions and state persisting out of the box. Inspired by Redux and Vuex. Built on top of React's context api.", | ||
"main": "lib/index.js", | ||
@@ -6,0 +6,0 @@ "scripts": { |
Sorry, the diff of this file is too big to display
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
495836
13088