-
Notifications
You must be signed in to change notification settings - Fork 130
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 cancel to ensure events do not continue firing #355
Fix cancel to ensure events do not continue firing #355
Conversation
@@ -520,6 +528,9 @@ final class AppSyncSubscriptionWithSync<Subscription: GraphQLSubscription, BaseQ | |||
/// Cancels and releases the subscription watcher, cancels active timers, and unregisters for system notifications. After | |||
/// invoking this method, the instance will be eligible for release. | |||
private func internalCancel() { | |||
isCancelled = true | |||
internalStateSyncQueue.cancelAllOperations() | |||
internalStateSyncQueue.isSuspended = true |
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.
do you think we can just check internalStateSyncQueue.isSuspended
to be true to not continue firing, instead of having the isCancelled
?
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.
What do you think of changing isCancelled
definition to:
private var isCancelled: Bool {
set {
internalStateSyncQueue.isSuspended = newValue
}
get {
return internalStateSyncQueue.isSuspended
}
}
Just so it is intentful of what is going on, and is also similar to AWSAppSyncSubscriptionWatcher
. Otherwise, I don't mind using internalStateSyncQueue.isSuspended
😄
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 think that might confusing if the internalStateSyncQueue is suspended for other reasons and isCancelled
represents that state. Then we should just name it isOperationsSuspended
or something. My original thought was that if we already have a property that we can check then why not just use it and reduce introducing a new variable. Thanks for calling out AWSAppSyncSubscriptionWatcher
, i'd say i think we should stick with the same pattern and keep what you currently have in the PR then
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.
LGTM
Issue #342, if available:
Description of changes:
calling cancel and holding strong retain cycle will not actually cancel as there are still operations that might exist on the internal operation queue.