use of com.amplifyframework.datastore.events.SyncQueriesStartedEvent in project amplify-android by aws-amplify.
the class SyncProcessor method hydrate.
/**
* The task of hydrating the DataStore either succeeds (with no return value),
* or it fails, with an explanation.
* @return An Rx {@link Completable} which can be used to perform the operation.
*/
Completable hydrate() {
final List<Completable> hydrationTasks = new ArrayList<>();
List<ModelSchema> modelSchemas = new ArrayList<>(modelProvider.modelSchemas().values());
// And sort them all, according to their model's topological order,
// So that when we save them, the references will exist.
TopologicalOrdering ordering = TopologicalOrdering.forRegisteredModels(schemaRegistry, modelProvider);
Collections.sort(modelSchemas, ordering::compare);
for (ModelSchema schema : modelSchemas) {
hydrationTasks.add(createHydrationTask(schema));
}
return Completable.concat(hydrationTasks).doOnSubscribe(ignore -> {
// This is where we trigger the syncQueriesStarted event since
// doOnSubscribe means that all upstream hydration tasks
// have started.
Amplify.Hub.publish(HubChannel.DATASTORE, HubEvent.create(DataStoreChannelEventName.SYNC_QUERIES_STARTED, new SyncQueriesStartedEvent(modelNames)));
}).doOnComplete(() -> {
// When the Completable completes, then emit syncQueriesReady.
Amplify.Hub.publish(HubChannel.DATASTORE, HubEvent.create(DataStoreChannelEventName.SYNC_QUERIES_READY));
});
}
use of com.amplifyframework.datastore.events.SyncQueriesStartedEvent in project amplify-android by aws-amplify.
the class HubEventDataObjectsTest method verifySyncQueriesStartedEvent.
/**
* Verify {@link SyncQueriesStartedEvent} behavior.
*/
@Test
public void verifySyncQueriesStartedEvent() {
SyncQueriesStartedEvent status1 = new SyncQueriesStartedEvent(new String[] { "Blog", "Post" });
SyncQueriesStartedEvent status2 = new SyncQueriesStartedEvent(new String[] { "Blog", "Post", "Car" });
SyncQueriesStartedEvent status3 = new SyncQueriesStartedEvent(new String[] { "Blog", "Post" });
EqualsToStringHashValidator.validate(status1, status2, status3);
}
Aggregations