Skip to content

Commit

Permalink
feat(@aws-amplify/datastore): Sync Status Notification. Performance I…
Browse files Browse the repository at this point in the history
…mprovements. (#5942)

* DataStore improvements

Sync status notification
Storage performance improvements
New DataStore.start() to kick of the sync process without having to run a query first
New default value for syncPageSize from 100 to 1000
  • Loading branch information
manueliglesias authored May 30, 2020
1 parent c63180a commit 67fac50
Show file tree
Hide file tree
Showing 24 changed files with 2,871 additions and 371 deletions.
36 changes: 36 additions & 0 deletions packages/core/__tests__/Hub-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,4 +258,40 @@ describe('Hub', () => {

expect(listener).not.toHaveBeenCalled();
});

test('Remove listener with unsubscribe function', () => {
const listener = jest.fn(() => {});

const unsubscribe = Hub.listen('auth', listener);

Hub.dispatch(
'auth',
{
event: 'signOut',
data: 'the user has been signed out',
message: 'User singout has taken place',
},
'Auth',
Symbol.for('amplify_default')
);

expect(listener).toHaveBeenCalled();

listener.mockReset();

unsubscribe();

Hub.dispatch(
'auth',
{
event: 'signOut2',
data: 'the user has been signed out',
message: 'User singout has taken place',
},
'Auth',
Symbol.for('amplify_default')
);

expect(listener).not.toHaveBeenCalled();
});
});
4 changes: 4 additions & 0 deletions packages/core/src/Hub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ export class HubClass {
callback: cb,
});
}

return () => {
this.remove(channel, cb);
};
}

private _toListeners(capsule: HubCapsule) {
Expand Down
42 changes: 42 additions & 0 deletions packages/datastore/__tests__/AsyncStorage.migration.data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[
[
"@AmplifyDatastore::datastore_Setting::Collection",
"[\"@AmplifyDatastore::datastore_Setting::Data::11ea-9555-bb149af0-bd99-91dc40efda36\"]"
],
[
"@AmplifyDatastore::datastore_Setting::Data::11ea-9555-bb149af0-bd99-91dc40efda36",
"{\"key\":\"schemaVersion\",\"value\":\"\\\"a66372d29356c40e7cd29e41527cead7\\\"\",\"id\":\"11ea-9555-bb149af0-bd99-91dc40efda36\"}"
],
[
"@AmplifyDatastore::user_BlogOwner::Collection",
"[\"@AmplifyDatastore::user_BlogOwner::Data::526a24a6-3ee5-43b5-80e0-19742733c109\",\"@AmplifyDatastore::user_BlogOwner::Data::74491d7a-6f4d-4e30-ba5b-492d631fdc37\",\"@AmplifyDatastore::user_BlogOwner::Data::55fd1422-d32e-4c84-8771-110a9829706e\"]"
],
[
"@AmplifyDatastore::user_BlogOwner::Data::526a24a6-3ee5-43b5-80e0-19742733c109",
"{\"name\":\"Owner 1\",\"id\":\"526a24a6-3ee5-43b5-80e0-19742733c109\"}"
],
[
"@AmplifyDatastore::user_Blog::Collection",
"[\"@AmplifyDatastore::user_Blog::Data::9b70f2ad-2963-45df-b357-97804eac37f4\",\"@AmplifyDatastore::user_Blog::Data::78e63f8e-df04-46ed-b99b-44e3ee8f58e5\",\"@AmplifyDatastore::user_Blog::Data::43e80c63-c1b3-4303-83ab-ba32e55370ae\"]"
],
[
"@AmplifyDatastore::user_Blog::Data::9b70f2ad-2963-45df-b357-97804eac37f4",
"{\"name\":\"Avatar: Last Airbender\",\"id\":\"9b70f2ad-2963-45df-b357-97804eac37f4\",\"blogOwnerId\":\"526a24a6-3ee5-43b5-80e0-19742733c109\"}"
],
[
"@AmplifyDatastore::user_BlogOwner::Data::74491d7a-6f4d-4e30-ba5b-492d631fdc37",
"{\"name\":\"Owner 2\",\"id\":\"74491d7a-6f4d-4e30-ba5b-492d631fdc37\"}"
],
[
"@AmplifyDatastore::user_Blog::Data::78e63f8e-df04-46ed-b99b-44e3ee8f58e5",
"{\"name\":\"blog2\",\"id\":\"78e63f8e-df04-46ed-b99b-44e3ee8f58e5\",\"blogOwnerId\":\"74491d7a-6f4d-4e30-ba5b-492d631fdc37\"}"
],
[
"@AmplifyDatastore::user_BlogOwner::Data::55fd1422-d32e-4c84-8771-110a9829706e",
"{\"name\":\"owner 3\",\"id\":\"55fd1422-d32e-4c84-8771-110a9829706e\"}"
],
[
"@AmplifyDatastore::user_Blog::Data::43e80c63-c1b3-4303-83ab-ba32e55370ae",
"{\"name\":\"Avatar 101\",\"id\":\"43e80c63-c1b3-4303-83ab-ba32e55370ae\",\"blogOwnerId\":\"55fd1422-d32e-4c84-8771-110a9829706e\"}"
]
]
Loading

0 comments on commit 67fac50

Please sign in to comment.