Socket
Socket
Sign inDemoInstall

dva-core

Package Overview
Dependencies
15
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.6.0-beta.4 to 1.6.0-beta.5

33

dist/index.js

@@ -432,2 +432,3 @@ 'use strict';

function getSaga(effects, model, onError, onEffect) {
var opts = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
return (

@@ -464,3 +465,3 @@ /*#__PURE__*/

case 0:
watcher = getWatcher(key, effects[key], model, onError, onEffect);
watcher = getWatcher(key, effects[key], model, onError, onEffect, opts);
_context2.next = 3;

@@ -516,3 +517,3 @@ return createSagaMiddleware.effects.fork(watcher);

function getWatcher(key, _effect, model, onError, onEffect) {
function getWatcher(key, _effect, model, onError, onEffect, opts) {
var _marked =

@@ -530,10 +531,10 @@ /*#__PURE__*/

effect = _effect2[0];
var opts = _effect[1];
var _opts = _effect[1];
if (opts && opts.type) {
type = opts.type;
if (_opts && _opts.type) {
type = _opts.type;
if (type === 'throttle') {
invariant(opts.ms, 'app.start: opts.ms should be defined if type is throttle');
ms = opts.ms;
invariant(_opts.ms, 'app.start: opts.ms should be defined if type is throttle');
ms = _opts.ms;
}

@@ -576,3 +577,3 @@ }

_context4.next = 7;
return effect.apply(void 0, _toConsumableArray(args.concat(createEffects(model))));
return effect.apply(void 0, _toConsumableArray(args.concat(createEffects(model, opts))));

@@ -679,6 +680,11 @@ case 7:

function createEffects(model) {
function createEffects(model, opts) {
function assertAction(type, name) {
invariant(type, 'dispatch: action should be a plain Object with type');
warning(type.indexOf("".concat(model.namespace).concat(NAMESPACE_SEP)) !== 0, "[".concat(name, "] ").concat(type, " should not be prefixed with namespace ").concat(model.namespace));
var _opts$namespacePrefix = opts.namespacePrefixWarning,
namespacePrefixWarning = _opts$namespacePrefix === void 0 ? true : _opts$namespacePrefix;
if (namespacePrefixWarning) {
warning(type.indexOf("".concat(model.namespace).concat(NAMESPACE_SEP)) !== 0, "[".concat(name, "] ").concat(type, " should not be prefixed with namespace ").concat(model.namespace));
}
}

@@ -993,3 +999,3 @@

if (m.effects) {
store.runSaga(app._getSaga(m.effects, m, onError, plugin.get('onEffect')));
store.runSaga(app._getSaga(m.effects, m, onError, plugin.get('onEffect'), hooksAndOpts));
}

@@ -1113,3 +1119,6 @@

reducers[m.namespace] = getReducer(m.reducers, m.state, plugin._handleActions);
if (m.effects) sagas.push(app._getSaga(m.effects, m, onError, plugin.get('onEffect')));
if (m.effects) {
sagas.push(app._getSaga(m.effects, m, onError, plugin.get('onEffect'), hooksAndOpts));
}
}

@@ -1116,0 +1125,0 @@ } catch (err) {

{
"name": "dva-core",
"version": "1.6.0-beta.4",
"version": "1.6.0-beta.5",
"description": "The core lightweight library for dva, based on redux and redux-saga.",

@@ -42,2 +42,3 @@ "main": "dist/index.js",

"devDependencies": {
"mm": "^2.5.0",
"redux": "^4.0.1"

@@ -44,0 +45,0 @@ },

@@ -7,7 +7,7 @@ import invariant from 'invariant';

export default function getSaga(effects, model, onError, onEffect) {
export default function getSaga(effects, model, onError, onEffect, opts = {}) {
return function*() {
for (const key in effects) {
if (Object.prototype.hasOwnProperty.call(effects, key)) {
const watcher = getWatcher(key, effects[key], model, onError, onEffect);
const watcher = getWatcher(key, effects[key], model, onError, onEffect, opts);
const task = yield sagaEffects.fork(watcher);

@@ -23,3 +23,3 @@ yield sagaEffects.fork(function*() {

function getWatcher(key, _effect, model, onError, onEffect) {
function getWatcher(key, _effect, model, onError, onEffect, opts) {
let effect = _effect;

@@ -52,3 +52,3 @@ let type = 'takeEvery';

yield sagaEffects.put({ type: `${key}${NAMESPACE_SEP}@@start` });
const ret = yield effect(...args.concat(createEffects(model)));
const ret = yield effect(...args.concat(createEffects(model, opts)));
yield sagaEffects.put({ type: `${key}${NAMESPACE_SEP}@@end` });

@@ -87,9 +87,14 @@ resolve(ret);

function createEffects(model) {
function createEffects(model, opts) {
function assertAction(type, name) {
invariant(type, 'dispatch: action should be a plain Object with type');
warning(
type.indexOf(`${model.namespace}${NAMESPACE_SEP}`) !== 0,
`[${name}] ${type} should not be prefixed with namespace ${model.namespace}`,
);
const { namespacePrefixWarning = true } = opts;
if (namespacePrefixWarning) {
warning(
type.indexOf(`${model.namespace}${NAMESPACE_SEP}`) !== 0,
`[${name}] ${type} should not be prefixed with namespace ${model.namespace}`,
);
}
}

@@ -96,0 +101,0 @@ function put(action) {

@@ -78,3 +78,3 @@ import { combineReducers } from 'redux';

if (m.effects) {
store.runSaga(app._getSaga(m.effects, m, onError, plugin.get('onEffect')));
store.runSaga(app._getSaga(m.effects, m, onError, plugin.get('onEffect'), hooksAndOpts));
}

@@ -181,3 +181,5 @@ if (m.subscriptions) {

reducers[m.namespace] = getReducer(m.reducers, m.state, plugin._handleActions);
if (m.effects) sagas.push(app._getSaga(m.effects, m, onError, plugin.get('onEffect')));
if (m.effects) {
sagas.push(app._getSaga(m.effects, m, onError, plugin.get('onEffect'), hooksAndOpts));
}
}

@@ -184,0 +186,0 @@ const reducerEnhancer = plugin.get('onReducer');

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc