Waiters composition
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 25/100
- Issue 类型
- 功能
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- javascript, react
- 领域
- frontend
调研方向
首先阅读 useWait API 和 createWaitingContext,然后检查 issue 中描述的 Waiter provider 方案。定义组合 waiter 如何传播子 waiter 的状态,以及是否支持手动 start/end;当 API 行为和边界情况完成规范定义,并根据现有 waiter 行为进行验证后,即视为完成。
由索引模型根据 Issue 内容生成。
描述
I've been using the library for a while and I noticed that I could simplify my code with something like composing of the waiters. For example, given that I have two waiters bar and baz, I would like to have foo waiter that is waiting if one of bar or baz is waiting.
Motivation
Now, first I was thinking about adding array argument support to isWaiting so that I could call isWaiting(["foo", "bar"]) or a bit more explicit convenience function isAnyWaiting(["foo", "bar"]).
But after looking into my code I realized it's not enough. In my case, I have some big component
Foo rendering smaller components Bar and Baz that wait on each other. That works fine with current API. It gets more convoluted when you would like to have some other component Qux that doesn't exactly want to know about the lower-level ones but needs to know if Foo or any of it's children waits. So currently in Qux you would need to write
const isFooWaiting = isWaiting("baz") && isWaiting("baz")
That's not ideal because Qux needs to know too much about Foo internals.
Proposal
Create a separate method that will create a new waiter if one of the child waiters is waiting. It could be similar in usage to createWaitingContext:
const { compose } = useWait();
const { isWaiting } = compose("Foo", ["Bar", "Baz"])
Foois a waiter, you can check if it's waiting withisWaiting("Foo")Foois always waiting ifBarorBazis waiting.- the open question is should you be able to manually start and end a composed waiter?
Anternative idea
Maybe instead adding a compose method, we could compose Waiter providers? It's just an idea, I don't know if it's possible or makes sense but provier could have an optional name and be a child of another warapper like this?
<Waiter>
<Waiter name="foo">
// ...
</Waiter>
</Waiter>
Then if the inner's anyWaiting() is true, foo is waiting in the outer waiter?
Again, it's just an idea.
- 主要语言
- JavaScript
- 星标
- 305
- 派生
- 28
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
f/react-wait 的其他 Issue
-
delta 未关闭
难度 5/5 一周以上 新手友好度 10/100
f/react-wait#15 ·
-
难度 1/5 1 小时以内 新手友好度 25/100
f/react-wait#14 ·
-
难度 3/5 1-2 天 新手友好度 35/100
f/react-wait#13 · 5 条评论 · 5 个 reaction ·
-
难度 5/5 一周以上 新手友好度 30/100
f/react-wait#8 · 1 个 reaction ·
-
难度 5/5 一周以上 新手友好度 20/100
f/react-wait#7 · 1 条评论 ·
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 70/100
-
难度 2/5 1-3 小时 新手友好度 75/100
mksglu/context-mode#1200 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
neondatabase/website#5944 ·
-
module: core
难度 2/5 1-3 小时 新手友好度 75/100
bigbluebutton/bigbluebutton#25849 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
jaegertracing/jaeger-ui#4506 ·