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

Fix cancel to ensure events do not continue firing #355

Merged
merged 1 commit into from
Mar 6, 2020

Conversation

LachlanMcCulloch
Copy link
Contributor

@LachlanMcCulloch LachlanMcCulloch commented Mar 4, 2020

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.

@@ -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
Copy link
Contributor

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?

Copy link
Contributor Author

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 😄

Copy link
Contributor

@lawmicha lawmicha Mar 6, 2020

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

Copy link
Contributor

@lawmicha lawmicha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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.

2 participants