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

支持promise返回值 #5

Closed
geekact opened this issue May 15, 2022 · 2 comments
Closed

支持promise返回值 #5

geekact opened this issue May 15, 2022 · 2 comments

Comments

@geekact
Copy link

geekact commented May 15, 2022

根据源码,limu判断produce的回调是否异步是通过isPromiseFn来判断。这只能支持async function() {}的写法,因此未考虑到用户写的是普通函数,最后返回的却是Promise实例的场景。

const result = produce(obj, (draft) => {
  return Promise.resolve().then(...);
});

因此建议参考immer https://github.com/immerjs/immer/blob/master/src/core/immerClass.ts#L101 ,替换掉isPromiseFn

@fantasticsoul
Copy link
Member

收到建议,感谢你的反馈,修复后会在此在此答复

@fantasticsoul
Copy link
Member

已支持,见版本1.3.0

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

2 participants