-
Notifications
You must be signed in to change notification settings - Fork 7
Swift UI example #46
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
Swift UI example #46
Conversation
lickel
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.
I want to play around with the eventing, but also, thanks!
| ], | ||
| animation: Animation.easeIn(duration: 1.0) | ||
| ) | ||
|
|
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.
Nit: remove this empty line
| List(models) { model in | ||
| row(for: model) | ||
| } | ||
| .listStyle(PlainListStyle()) |
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.
Nit: .listStype(.plain)
| } | ||
| } | ||
|
|
||
| static var viewController: UIHostingController<SwiftUIView> { |
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.
Interesting... haven't seen this pattern before...
But will ask that you move this into UIKit and keep the view "pure"
|
OK, tracked it down to: static func fetchDefinition() -> FetchDefinition<Self> {
let dataResetTokens: [ModelClearedToken<Self>] = [
ModelClearedToken(),
]
return FetchDefinition<Self>(
request: { completion in
completion(fetchAll())
},
objectCreationToken: ModelCreationToken<Self>(),
dataResetTokens: dataResetTokens
)
}
}Because it does |
|
I’ll ask that you revert the property wrapper and I’ll take a look at this in a separate PR |
| return FetchDefinition<Self>( | ||
| request: { completion in | ||
| completion(fetchAll()) | ||
| DispatchQueue.main.async { |
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.
@lickel This will make the swiftUI example work as expected.
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.
Alternatively I was able to address the issue modifying the FetchableRequest, by wrapping the fetch definition like so a new view context is guarenteed on performFetch calls.
I have a separate branch with this change. This has no impact on definitions that fetch async on a background thread and call to main for their completion.
main...MerinoA:FetchRequests:fix-fetchableRequests
But I will leave that solution up to you.
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.
yup makes sense. I think I'd still like to fix it somewhere in the framework, but thanks!
This pull request adds the basic example of the 'FetchableRequest' property wrapper in a swiftUI view.
During the implementation of this example I discovered an issue when using the property wrapper. The initial data would not render on the initial render pass.
To remedy this behavior, the initial setting of the wrappedValue within the sink closure is wrapped 'DispatchQueue.main.async' call. Subsequent calls are not to maintain swiftUI's animations.