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

Adding cancellable interface to RemoteSyncEngine components #323

Merged
merged 1 commit into from
Feb 20, 2020

Conversation

wooj2
Copy link
Contributor

@wooj2 wooj2 commented Feb 16, 2020

In this PR, we are adding a cancellable interface, but still not calling cancel -- that will be done in the next PR

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@wooj2 wooj2 requested a review from palpatim February 16, 2020 22:42
@wooj2 wooj2 added datastore Issues related to the DataStore category P0 labels Feb 17, 2020
self.remoteSyncTopicPublisher.send(.performedInitialSync)
self.stateMachine.notify(action: .performedInitialSync)
}
semaphore.signal()
Copy link
Member

Choose a reason for hiding this comment

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

As noted in the TODO on L213 above, I assume we'll be removing the semaphore once we complete the cancelation wiring?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe what you are proposing is reusing the recieve/recieveCompletion: strategy we are using between the remoteSyncEngine and the Subscriptions with the initialSync code. I hadn't thought about it but yes, we could do something similar down the line.


import Foundation

//Note: There is already a Cancellable in Core/Support/Cancellable.swift, which does not seem to be
Copy link
Member

Choose a reason for hiding this comment

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

Rather than re-implement, import the core cancellable with import Amplify where needed. Otherwise we'll have Combine.Cancellable, Amplify.Cancellable, and AWSDataStoreCategoryPlugin.Cancellable all potentially conflicting.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried importing cancellable with import Amplify, and tried extending classes with Amplify.Cancellable, but wasn't able to fix this. I opened an issue here to take a look at cleaning this up:
#328

Copy link
Contributor

Choose a reason for hiding this comment

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

That's weird, by looking at the type declaration I don't see anything that could block it from being used outside of core when importing Amplify. Is it an Xcode cache issue?

@wooj2 wooj2 requested a review from drochetti February 18, 2020 17:53
Copy link
Contributor

@drochetti drochetti left a comment

Choose a reason for hiding this comment

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

I left two comments, but since we synced up about this PR already, I'll approve. If you believe the comments make sense and further action is needed, feel free to follow up with another PR.

Comment on lines +51 to +52
asyncEvents.cancel()
mapper = nil
Copy link
Contributor

Choose a reason for hiding this comment

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

  • should mapper be cancelable as well?
  • does asyncEvents require cleanup?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, and yes. These two items are fixed here: :)
https://github.com/aws-amplify/amplify-ios/pull/326/files


import Foundation

//Note: There is already a Cancellable in Core/Support/Cancellable.swift, which does not seem to be
Copy link
Contributor

Choose a reason for hiding this comment

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

That's weird, by looking at the type declaration I don't see anything that could block it from being used outside of core when importing Amplify. Is it an Xcode cache issue?

@wooj2 wooj2 force-pushed the master-RSEState-Restart branch from 2a49d3a to 782de9c Compare February 20, 2020 00:54
@wooj2 wooj2 changed the base branch from master-RSEState-Restart to master February 20, 2020 00:55
@wooj2 wooj2 force-pushed the master-RSEState-Restart-cancel branch from bb1b536 to d7bfd59 Compare February 20, 2020 00:56
@wooj2 wooj2 merged commit e9a4f03 into master Feb 20, 2020
@wooj2 wooj2 deleted the master-RSEState-Restart-cancel branch February 20, 2020 01:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
datastore Issues related to the DataStore category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants