-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Fix issue with ObservedResults and searchable #8114
Conversation
ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction"> | ||
<ActionContent | ||
title = "Run Script" | ||
scriptText = "killall Simulator defaults write com.apple.iphonesimulator ConnectHardwareKeyboard -bool false "> |
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.
Having the hardware keyboard option enabled will give a high chance of characters being missed when tests are writing to text fields.
@@ -237,6 +242,7 @@ private class ObservableStorage<ObservedType>: ObservableObject where ObservedTy | |||
willSet { | |||
if newValue != value { | |||
objectWillChange.send() | |||
objectWillChange.update(value: newValue) |
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.
When ObservedResults
is setup the publisher is passed RLMResults<ResultType>.emptyDetached()
. When the actual Results
to be observed is ready we need to update the publisher to hold a reference to it. Otherwise receive()
will never setup the ObservationSubscription
again once the original token is invalidated.
cba137f
to
868bb9f
Compare
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.
It would be nice to have a test which really test this particular use case. If I run the SwiftUI tests removing the update function, all the tests are completing successfully (running on ios16), so I cannot reproduce the original issue. The way the issue seems to be happenignwhen we update the realm without using the property wrapper ($observedResults.append(:)
), or maybe I'm wrong.
b3ff016
to
28332fa
Compare
28332fa
to
ab976c1
Compare
@@ -966,7 +966,9 @@ public class UserPublisher: Publisher { | |||
/// :nodoc: | |||
public func receive<S>(subscriber: S) where S: Subscriber, S.Failure == Never, Output == S.Input { | |||
let token = user.subscribe { _ in | |||
_ = subscriber.receive(self.user) | |||
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.
This is not a valid thing to do, and it's producing (correct) sendability warnings.
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'll revert this. Is the correct approach to have the end user bounce to the main thread instead when calling something which mutates theUser
?
Addresses issue where observation subscription is cancelled on initial view refresh.
This PR fixes up the SwiftUITests for iOS 16 too.
Fixes: #8096
Fixes: #8132