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
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion dumi/docs/concepts/state/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ export interface IState<V> {
validate(): Promise<ValidateResult<V>>
/** Configure when state should be disabled. */
disableWhen(predictFn: () => boolean): this
/** 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

}
```

Expand Down Expand Up @@ -92,7 +96,7 @@ That's why there's a boolean field `activated` for states.

States will not be auto-validated until it becomes **activated**. And they will become (and stay) activated if one of these happens:

1. Value changed by user interactions (method `onChange()` is called).
1. Value changed by user interactions (method `onChange()` is called).
2. State imperatively validated (method `validate()` is called).

### Own Error
Expand Down
Loading