Rename the progress function to better reflect purpose

refactored registration code to remove the unneccesary lambda
This commit is contained in:
blagoev 2017-06-28 15:02:28 +03:00
parent 55542a492e
commit f54487c6cc
2 changed files with 5 additions and 8 deletions

View File

@ -586,7 +586,7 @@ void RealmClass<T>::wait_for_download_completion(ContextType ctx, FunctionType,
auto realm = realm::Realm::get_shared_realm(config);
if (auto sync_config = config.sync_config)
{
static const String progressFuncName = "_onProgress";
static const String progressFuncName = "_onDownloadProgress";
bool progressFuncDefined = false;
if (!Value::is_boolean(ctx, sync_config_value) && !Value::is_undefined(ctx, sync_config_value))
{
@ -615,11 +615,8 @@ void RealmClass<T>::wait_for_download_completion(ContextType ctx, FunctionType,
if (user && user->state() != SyncUser::State::Error) {
if (auto session = user->session_for_on_disk_path(config.path)) {
if (progressFuncDefined) {
session->register_progress_notifier([=](uint64_t transferred_bytes, uint64_t transferrable_bytes) {
progressFunc(transferred_bytes, transferrable_bytes);
}, SyncSession::NotifierType::download, false);
}
session->register_progress_notifier(std::move(progressFunc), SyncSession::NotifierType::download, false);
}
session->wait_for_download_completion([=](std::error_code error_code) {
realm->close(); //capture and keep realm instance for until here

View File

@ -247,7 +247,7 @@ module.exports = {
sync: {
user,
url: `realm://localhost:9080/~/${realmName}`,
_onProgress: (transferred, remaining) => {
_onDownloadProgress: (transferred, remaining) => {
progressNotificationCalled = true
},
},
@ -279,7 +279,7 @@ module.exports = {
let progressNotificationCalled = false;
let config = {
sync: { user, url: `realm://localhost:9080/~/${realmName}`,
_onProgress: (transferred, remaining) => {
_onDownloadProgress: (transferred, remaining) => {
progressNotificationCalled = true
},
},