Skip to content

Support KeyPaths with multiple return types - #1

Open
MMP0 wants to merge 7 commits into
matis-schotte:masterfrom
MMP0:patch-1
Open

Support KeyPaths with multiple return types#1
MMP0 wants to merge 7 commits into
matis-schotte:masterfrom
MMP0:patch-1

Conversation

@MMP0

@MMP0 MMP0 commented Jun 26, 2022

Copy link
Copy Markdown

Hello.
I’m planning to use this in my project, but I’m stumbling on some things.

When using multiple KeyPaths, you cannot specify KeyPaths with different return types at the same time, because generic types of the KeyPath array is inferred and limited to one type.

@PublishedKVO([\.isIndeterminate, \.fractionCompleted]) // <- Bool, Double
var progress = Progress()

So to make it more flexible, I changed the argument of the function to a set of PartialKeyPath<Value> (type-ereasing).
The return type isn’t that important since it’s only for detecting value changes.

Also there was an issue where the event wouldn’t fire when the SwiftUI view was updated and the wrappedValue changed, so I made it to rehook when the setter was called.

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.

1 participant