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

make addDisposer public #88

Merged
merged 5 commits into from
Nov 8, 2022
Merged

make addDisposer public #88

merged 5 commits into from
Nov 8, 2022

Conversation

lzfee0227
Copy link
Collaborator

@lzfee0227 lzfee0227 commented Nov 8, 2022

case: add disposer (sth like mobx reaction) in react hooks

resolve react dev version

/** Do dispose. */
dispose(): void
/** Collect the disposer function. */
addDisposer(disposer: Disposer): void
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个是需要加到 IState 上的吗?以及我看 IState 对应的代码并还没有加?

Copy link
Collaborator Author

@lzfee0227 lzfee0227 Nov 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

有道理 现在加了 4420cd3
加之前就能用是因为实际上都 extends 了 Disposable

Copy link
Collaborator

@nighca nighca Nov 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

加之前就能用是因为实际上都 extends 了 Disposable

那是不是说明在具体的实现(FieldStateFormState、..)上有 addDisposer 平时就够用了,而不一定要体现在接口上?

体现在接口上的话会给每个对接口的实现(包括当下的跟将来的)增加负担

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

也行
不过文档哪里适合写这个呢(哪些有 add disposer)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不过文档哪里适合写这个呢(哪些有 add disposer)

不用写在文档里吧,自己通过 TS 的类型就能发现;事实上是绝大部分内置的 class XxxState 都有 addDisposer

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

事实上是绝大部分内置的 class XxxState 都有 addDisposer

@nighca nighca merged commit fca7ebb into qiniu:master Nov 8, 2022
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

Successfully merging this pull request may close these issues.

2 participants