Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

redux-saga-model

Package Overview
Dependencies
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-saga-model - npm Package Compare versions

Comparing version 0.2.5 to 0.2.6

78

lib/index.js

@@ -159,3 +159,3 @@ "use strict";

return model.namespace === namespace;
}), "modelManager.model: namespace should be unique :" + model.namespace);
}), "modelManager.model: namespace should be unique :" + model.namespace + " ,if use webpack please use register with hot parameter");

@@ -239,2 +239,3 @@ (0, _invariant2.default)(!model.subscriptions || (0, _isPlainObject2.default)(model.subscriptions) || (0, _lodash2.default)(model.subscriptions), "modelManager.model: subscriptions should be Object or Function");

* @param {any} namespace
* @param {any} m model
* @returns

@@ -255,6 +256,12 @@ * @memberof sagaModelManager

store.replaceReducer(createReducer(store.asyncReducers));
store.dispatch({ type: "@@saga-model/UPDATE" });
store.dispatch({
type: "@@saga-model/UPDATE"
});
// Cancel effects
store.dispatch({ type: namespace + "/@@CANCEL_EFFECTS" });
// Cancel sagas
m.sagas && (0, _keys2.default)(m.sagas).forEach(function (key) {
store.dispatch({
type: key + "/@@CANCEL_EFFECTS"
});
});

@@ -301,2 +308,4 @@ // unlisten subscrioptions

console.log(privateProps.models);
return this;

@@ -357,6 +366,25 @@ }

} catch (e) {
console.error('if use webpack please use register with hot parameter');
console.error(e);
console.error(m.namespace + " register failed");
// 不打断系统流程 只是中断当前对应的 model 注册
return;
}
// 如果是热替换且已存在对应的 namespace 则重新缓存
var index = -1;
if (hot) {
privatePropsModels.some(function (model, i) {
return model.namespace === m.namespace ? (index = i, true) : false;
});
}
if (index >= 0) {
m.sagas && (0, _keys2.default)(m.sagas).forEach(function (key) {
store.dispatch({
type: key + "/@@CANCEL_EFFECTS"
});
});
// delete model
privatePropsModels.splice(index, 1);
}
privatePropsModels.push(m);

@@ -367,12 +395,7 @@

store.replaceReducer(createReducer(store.asyncReducers));
store.dispatch({
type: "@@saga-model/UPDATE"
});
// sagas
if (m.sagas) {
// 注销原先的 saga
if (hot) {
(0, _keys2.default)(m.sagas).forEach(function (key) {
store.dispatch({
type: key + "/@@CANCEL_EFFECTS"
});
});
}
store.runSaga(_this3.getSaga(m.sagas, m, onError));

@@ -440,3 +463,6 @@ }

return { unlisteners: unlisteners, noneFunctionSubscriptions: noneFunctionSubscriptions };
return {
unlisteners: unlisteners,
noneFunctionSubscriptions: noneFunctionSubscriptions
};
}

@@ -633,11 +659,11 @@

/**
* 针对每个 saga 进行处理
* 最终返回一个生成器
*
* @param {any} key saga.key 已被打上 namespace 的 tag
* @param {any} _saga saga.value
* @param {any} model
* @param {any} onError
* @returns
*/
* 针对每个 saga 进行处理
* 最终返回一个生成器
*
* @param {any} key saga.key 已被打上 namespace 的 tag
* @param {any} _saga saga.value
* @param {any} model
* @param {any} onError
* @returns
*/

@@ -857,8 +883,8 @@ }, {

for (var _iterator3 = (0, _getIterator3.default)(privateProps.models), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
var m = _step3.value;
var _m = _step3.value;
// 一个命名空间放一个根级 reducer 每个 model.reducers 都已被打上 namespace 的印记,这里为什么还要区分呢。
reducers[m.namespace] = this.getReducer(m.reducers, m.state, m);
reducers[_m.namespace] = this.getReducer(_m.reducers, _m.state, _m);
// sagas 不是必须的
if (m.sagas) sagas.push(this.getSaga(m.sagas, m, onErrorWrapper));
if (_m.sagas) sagas.push(this.getSaga(_m.sagas, _m, onErrorWrapper));
}

@@ -865,0 +891,0 @@

{
"name": "redux-saga-model",
"version": "0.2.5",
"version": "0.2.6",
"dependencies": {

@@ -5,0 +5,0 @@ "flatten": "^1.0.2",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc