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

[Feature Request] 一些语法糖 #166

Open
Tanimodori opened this issue Sep 29, 2022 · 1 comment
Open

[Feature Request] 一些语法糖 #166

Tanimodori opened this issue Sep 29, 2022 · 1 comment
Labels

Comments

@Tanimodori
Copy link

Tanimodori commented Sep 29, 2022

需求描述 Feature Description

1. Options.ready 检测truthy

在依赖请求中比较有用。目前ready只接受Ref<Boolean>,所以不能直接传Ref<Data>,需要写computed。希望可以接受Ref<unknown>并检测truthy。

  const api1Context = useRequest(api1);
  /*
  const api2Context = useRequest(api2, {
    ready: api1Context.data, // 类型错误
  };
  */
  const isApi1Ready = computed(() => !!api1Context.data);
  const api2Context = useRequest(api2, {
    ready: isApi1Ready, // 类型正确
  });

2. State.finished (或者叫loadedready之类的也行)

这个其实是对标useAxiosisFinished ,因为如果给了initialData的话,没有办法从State判断当前是不是已经加载完成了,还是得监听onSuccessonAfter之类的事件。每次都要写一段样板代码也不是很方便,还是希望能加上。

3. refreshDeps 接受单个WatchSource

单纯的语法糖,和vuewatch一样,用isArray判断一下就好了。

建议的解决方案 Proposed Solution

其他信息 Other information

@John60676
Copy link
Member

Good suggestion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants