syncPending method
- void onComplete(
- GemError error
Uploads the local activities that are new or changed.
The outcome of each upload reaches ActivityStoreListener.registerOnActivityUploadFinished.
Parameters
onComplete: Called with GemError.success when the sync started, or with GemError.notSupported when ActivityStoreConfig.syncEnabled is false.
Returns
- The ProgressListener of the call, or null when it could not start.
Implementation
ProgressListener? syncPending({void Function(GemError error)? onComplete}) {
final EventDrivenProgressListener progressListener =
EventDrivenProgressListener();
GemKitPlatform.instance.registerEventHandler(
progressListener.id,
progressListener,
);
progressListener.registerOnCompleteWithData((
int err,
String hint,
Map<dynamic, dynamic> json,
) {
GemKitPlatform.instance.unregisterEventHandler(progressListener.id);
onComplete?.call(GemErrorExtension.fromCode(err));
});
final OperationResult resultString = objectMethod(
pointerId,
'ActivityStore',
'syncPending',
args: <String, dynamic>{'listener': progressListener.id},
);
final GemError errorCode = GemErrorExtension.fromCode(
resultString['result'],
);
if (errorCode != GemError.success) {
onComplete?.call(errorCode);
return null;
}
return progressListener;
}