Dva: 为什么dva文档中存在call直接可以调用effect的例子,实际却无法使用

Created on 21 Feb 2019  ·  6Comments  ·  Source: dvajs/dva

Code to reproduce the issue: (请提供可复现的代码或者步骤)

这是dva文档中的一部分,里面用了call来调用某个model下effect的方法
_20190221195854

Expected behavior: (预期的正常效果)

这样用的应该是为了同步顺序调用几个effect

Actual behavior: (实际效果)

但实际在代码中使用好像call只能传入function参数

*abc({ payload }, {put, call,take}) {
          yield call({type: 'a/b',payload: {...}});
    },

报错
index.js:1 uncaught at check call: argument [object Object] is not a function
不知道是我理解错了,还是使用有问题? 求教大佬

Versions of packages used: (哪个库的哪个版本出现的问题)

"dva": "^2.4.0",

wontfix

Most helpful comment

All 6 comments

后续流程你可以通过componentWillReceive或者componentUpdated中判断并执行

你可以去看看redux-saga的文档 会帮助理解dva的call、take、put等等

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

碰到同样问题+1 有大佬细说下么 现在用的 yield put({type: 'fetchCurrent'}); 但是是异步的

碰到同样问题+1 有大佬细说下么 现在用的 yield put({type: 'fetchCurrent'}); 但是是异步的

//同步阻塞其他action
yield put.resolve({type: 'fetchCurrent'});
//异步其他action
yield put({type: 'fetchCurrent'});

Was this page helpful?
0 / 5 - 0 ratings