-
Notifications
You must be signed in to change notification settings - Fork 44
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
Equatable sinks prototype #254
base: tomb/swiftui-testbed
Are you sure you want to change the base?
Conversation
} | ||
} | ||
|
||
// I guess this could be upstreamed to Blueprint |
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.
Oh yeah, I think I've seen this go by in POS
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'm just now noticing that SwiftUI's FocusState
is not Equatable. That makes it harder for View
s to be Equatable, but I presume SwiftUI's internal comparison of non-Equatable View types handles it well.
} | ||
} | ||
|
||
// I guess this could be upstreamed to Blueprint |
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'm just now noticing that SwiftUI's FocusState
is not Equatable. That makes it harder for View
s to be Equatable, but I presume SwiftUI's internal comparison of non-Equatable View types handles it well.
let close: (() -> Void)? | ||
|
||
typealias Output = Never | ||
enum Output { | ||
case close | ||
} |
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.
} | ||
|
||
struct State { | ||
var title: String | ||
var isAllCaps: Bool | ||
let trampoline = SinkTrampoline() |
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.
This seems like the best/only way to create a persistent identity that we can use to implement StableSink.==
👍
let sink = context.makeSink(of: actionType) | ||
|
||
sinks[ObjectIdentifier(actionType)] = sink | ||
|
||
return StableSink(trampoline: self) |
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 wonder if we could pass sink
into StableSink.init
here and implement StableSink.send
using that reference, allowing us to delete sinks
, bounce
, and destination
. That would also avoid retaining any Workflow.Sink
that is no longer referenced by any StableSink
Maintaining sinks
does add some safety (against this, I think?) by ensuring we use the latest Workflow.Sink
that the RenderContext
has given us for a given Action
type. But not total safety, because we're not evicting from sinks
every sink that wasn't remade during the last render
.
Is the need for that safety greater when the Rendering holds StableSink
s rather than functions closing over Workflow.Sink
s?
No description provided.