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

考虑设计增加使用一次后就自动 closeExternalResource #1377

Closed
Him188 opened this issue Jul 1, 2021 · 4 comments · Fixed by #1383 or #1392
Closed

考虑设计增加使用一次后就自动 closeExternalResource #1377

Him188 opened this issue Jul 1, 2021 · 4 comments · Fixed by #1383 or #1392
Labels
N 优先级: 一般 t:enhancement 类型: 现有功能上的优化
Milestone

Comments

@Him188
Copy link
Member

Him188 commented Jul 1, 2021

ER 很多时候只会使用一次, 而用户很容易忘记关闭, 虽然即使增加了自动关闭也需要用户指定参数 autoClose = true.

可能的方案: 为现有 ER 构造函数添加参数 autoClose: Boolean = false

@Him188 Him188 added t:enhancement 类型: 现有功能上的优化 N 优先级: 一般 labels Jul 1, 2021
@Him188 Him188 added this to the Backlog milestone Jul 1, 2021
@Him188 Him188 linked a pull request Jul 2, 2021 that will close this issue
@Him188 Him188 modified the milestones: Backlog, 2.7-M2 Jul 5, 2021
@Him188 Him188 linked a pull request Jul 6, 2021 that will close this issue
@Him188 Him188 reopened this Jul 6, 2021
@Him188 Him188 modified the milestones: 2.7-M2, 2.8-M1, 2.8 Jul 6, 2021
@AdoptOSS
Copy link
Contributor

AdoptOSS commented Jul 8, 2021

建议修改toExternalResource名称,这个名字实在不像是要close的那种

@sandtechnology
Copy link
Collaborator

sandtechnology commented Jul 8, 2021

toReusableExternalResource
toTempExternalResource

可以分成这两个?

@AdoptOSS
Copy link
Contributor

AdoptOSS commented Jul 8, 2021

其实我更偏向于引入useAsExternalResource(...lambda),让kotlin变量作用域和资源实际生命周期保持一致

@Karlatemp
Copy link
Member

其实我更偏向于引入useAsExternalResource(...lambda),让kotlin变量作用域和资源实际生命周期保持一致

ExternalResource 实现 Closeable, 是能直接 res.use {}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
N 优先级: 一般 t:enhancement 类型: 现有功能上的优化
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants