Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yield take()卡住 #1267

Closed
SiBorya opened this issue Oct 9, 2017 · 2 comments
Closed

yield take()卡住 #1267

SiBorya opened this issue Oct 9, 2017 · 2 comments

Comments

@SiBorya
Copy link

SiBorya commented Oct 9, 2017

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

   ` yield put({
      type: 'updateState',
      payload: {data},
    });
    yield take('updateState/@@end');`

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

正常执行

Actual behavior: (实际效果)

程序卡在yield take(),没有异常抛出。updateState正常执行完成。

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

2.0.3

@SiBorya
Copy link
Author

SiBorya commented Oct 9, 2017

sorrycc/blog#48的描述,reducer应该是不会触发这个action。
那么问题又来了,有foo和bar两个effect,foo需要bar返回的数据,应该用何种方式获取?
yield put({type: 'bar'}); yield take('bar/@@end'); const data = yield select(_ => _.data);
这里并不能获取到bar的结果。

@programmer-yang
Copy link

programmer-yang commented Nov 29, 2017

@Kroderia
hi

effect 前后会额外触发 /@@start 和 /@@EnD 的 action,可利用此约定实现 put 的同步执行

1 你的put操作必须是一个effect才能触发到这个effect/@@start|endtake
2 第二个问题,两个effect,一个依赖另外一个的结果,能否在一个effect.then里再dispatch第二个effect
如果一定要在effect中堵塞调用第二个effect可以用利用take@@end的机制来实现
参考这个 issues/1212

@sorrycc sorrycc closed this as completed Apr 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants