-
Notifications
You must be signed in to change notification settings - Fork 20
feat: track updating selections with row IDs #831
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
base: main
Are you sure you want to change the base?
Conversation
|
I updated the mise task headers from to to silence the deprecation warning in newer mise versions. Happy to revert if you’d rather keep the old header. |
fortmarek
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for the PR and sorry for taking longer to review this. I wonder if we can take the opportunity to rethink the API a bit to make supporting this use case more elegant 👀
| /// An interactive table that keeps updating as new data arrives. | ||
| struct UpdatingSelectableTable<Updates: AsyncSequence> where Updates.Element == TableData { | ||
| /// @unchecked Sendable: rendering and state access are serialized by internal queues. | ||
| struct UpdatingSelectableTable<Updates: AsyncSequence>: @unchecked Sendable where Updates.Element == TableData { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd love us to figure out a way not to add the @unchecked Sendable – is there a way to implement the behavior with structured concurrency constructs?
| public let rows: [TableRow] | ||
|
|
||
| /// Optional row identifiers aligned to `rows` (used for selection tracking in updating tables) | ||
| public let rowIDs: [AnyHashable]? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of a rowIDs property, I'd consider making the TableRow conform to Identifiable and basically make it more like a SwiftUI List. I'd love the API to be more like:
TableData(
data,
columns: columns,
rows: [
TerminalRow { element in
element.title
},
TerminalRow { element in
element.subtitle
}
])And if data would be Identifiable, the selection could work based on the ID (without having an explicit rowIDs property). It would require some type gymnastics to make this non-breaking, but I think it should be possible.
Wdyt? cc @pepicrft
Uh oh!
There was an error while loading. Please reload this page.