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

Support KeyPaths with multiple return types #1

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

MMP0
Copy link

@MMP0 MMP0 commented Jun 26, 2022

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