amplify-swift
amplify-swift copied to clipboard
fix(datastore): observeQuery snapshot on ready event
Issue #, if available: https://github.com/aws-amplify/amplify-ios/issues/1759
Description of changes: ObserveQuery is an API that provides a stream of data snapshots including the sync state. Roughly the behavior of the snapshot's emit intervals is this: The intervals adjusted based on the sync state, sending less frequent snapshots during the syncing process and more frequent snapshots after is synced. The issue, which was confirmed other platforms do not have and is expected, is that in between the last snapshot during sync and the first snapshot after sync is that the operation is missing a snapshot to indicate the sync state toggle. The customer impact is when there is an infrequent number item changes after syncing then the first snapshot after sync is delayed until there is a new item change, causing a large interval between the two snapshots.
The fix is to listen for the datastore ready event and emit a snapshot when receiving the ready event, which introduces the behavior of the missing snapshot.
Check points: (check or cross out if not relevant)
- [ ] Added new tests to cover change, if needed
- [ ] Build succeeds with all target using Swift Package Manager
- [ ] All unit tests pass
- [ ] All integration tests pass
- [ ] Security oriented best practices and standards are followed (e.g. using input sanitization, principle of least privilege, etc)
- [ ] Documentation update for the change if required
- [ ] PR title conforms to conventional commit style
- [ ] If breaking change, documentation/changelog update with migration instructions
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Codecov Report
Merging #2105 (3d7a733) into main (f0c3534) will decrease coverage by
0.01%. The diff coverage is57.14%.
@@ Coverage Diff @@
## main #2105 +/- ##
==========================================
- Coverage 59.50% 59.48% -0.02%
==========================================
Files 719 719
Lines 22561 22568 +7
==========================================
Hits 13425 13425
- Misses 9136 9143 +7
| Flag | Coverage Δ | |
|---|---|---|
| API_plugin_unit_test | 62.47% <ø> (-0.10%) |
:arrow_down: |
| AWSPluginsCore | 70.29% <ø> (+0.07%) |
:arrow_up: |
| Amplify | 48.20% <ø> (-0.04%) |
:arrow_down: |
| Analytics_plugin_unit_test | 71.09% <ø> (ø) |
|
| Auth_plugin_unit_test | 78.16% <ø> (ø) |
|
| DataStore_plugin_unit_test | 75.60% <57.14%> (-0.04%) |
:arrow_down: |
| Geo_plugin_unit_test | 52.12% <ø> (ø) |
|
| Predictions_plugin_unit_test | 26.81% <ø> (ø) |
|
| Storage_plugin_unit_test | 58.04% <ø> (ø) |
Flags with carried forward coverage won't be shown. Click here to find out more.
| Impacted Files | Coverage Δ | |
|---|---|---|
| ...gin/Subscribe/DataStoreObserveQueryOperation.swift | 75.00% <57.14%> (+0.35%) |
:arrow_up: |
| Amplify/Categories/Hub/HubFilter.swift | 47.36% <0.00%> (-10.53%) |
:arrow_down: |
| ...lugin/Operation/AWSAPIOperation+APIOperation.swift | 73.68% <0.00%> (-5.27%) |
:arrow_down: |
| ...oreCategoryPlugin/Sync/Support/Model+Compare.swift | 68.75% <0.00%> (-3.13%) |
:arrow_down: |
| ...e/AWSPluginsCore/Auth/AWSAuthServiceBehavior.swift | 87.50% <0.00%> (+12.50%) |
:arrow_up: |
:mega: Codecov can now indicate which changes are the most critical in Pull Requests. Learn more