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

effects 里面导入通过模块导入出来的异步方法使用isAsyncFunction方法判断为什么变成了Function 而不是 AsyncFunction #6

Open
jshuaishuai opened this issue Jul 5, 2021 · 1 comment

Comments

@jshuaishuai
Copy link

这个是例子上的代码

export default {
  state: {
    id: 123,
    name: 'cc',
  },
  reducers: {
    setName(state, payload) {
      // console.log(state, payload);

      return {
        ...state,
        ...payload,
      };
    },
  },
  effects: {
    async setNameAsync(dispatch, state, payload) {
      await new Promise((resolve) => setTimeout(resolve, 1000));
      dispatch({
        type: 'setName',
        payload,
      });
    },
  },
};

image

Object.getPrototypeOf(async function(){}).constructor 判断并不是AsyncFunction 为什么,但是在浏览器里面打开确实可以判断出是异步函数
image

@jshuaishuai
Copy link
Author

如果是这样是不是 我所有的异步方法都会去走同步更新?

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

1 participant