Skip to content

<object>.cancelSync

The <object>.cancelSync function attempts to cancel an in progress object sync operation. The operation fails if the task syncing is already finished, throws an error, or does not support the Cancel operation.

Volt MX Iris (JavaScript)

Note:
  • Not supported for Mobile Web, Desktop Web and Desktop Native channels.
  • Supported for Windows from V8 SP4 Fix Pack 12 onwards.

Signature

<VMXObj>.cancelSync(options, onSuccess, onFailure);

Parameters

ParameterTypeDescriptionRequired
optionsJSONReserved for future use, so the parameter is insignificant. But, the developer must pass some value such as null or { }.Yes
onSuccessFunctionThe function is invoked when the cancellation is successful.Yes
onFailureFunctionThe function is invoked when the cancellation fails.Yes

Return Type

void

Example

var syncObject = new voltmx.sdk.VMXObj("Managers");

// Define Sync options
var syncOptions = {};
syncOptions.downloadBatchSize = 100;
syncOptions.uploadBatchSize = 200;
syncOptions.getSyncStats = true;

// Start Sync asynchronously
syncObject.startSync(syncOptions,
function(res) {
alert("Object sync successful”);
},
function(err)
{
alert("
Object sync failed with error: " + JSON.stringify(err));
},
function(progressCallback)
{
alert("
Object sync progress event received ");
});

// Now attempt to Cancel Sync
// passing an empty map for options parameter
syncObject.cancelSync({},
function(res)
{
alert("
Object sync cancellation successful ");
},
function(err)
{
alert("
Object sync failed with error: " + JSON.stringify(err));
});

Android (Java)

Signature

public void cancelSync(HashMap<String, Object> options, final VMXCallback syncCancellationCallback)

Parameters

ParameterTypeDescriptionRequired
optionsHashMap<String, Object>Reserved for future use, so the parameter is insignificant. But, the developer must pass some value such as null or new HashMap<String, Object>().Yes
syncCancellationCallbackVMXCallbackApplication implements onSuccess and onFailure methods of VMXCallback interface.Yes

Return Type

void

Example

VMXObj syncObject = new VMXObj("Managers");

//Define Sync options
HashMap < String, Object > syncOptions = new HashMap < String, Object > ();
syncOptions.put("downloadBatchSize", "100");
syncOptions.put("uploadBatchSize", "200");
syncOptions.put("getSyncStats", "true");

// Start Sync asynchronously
syncObject.startSync(syncOptions,
new VMXCallback() {
@Override
public void onSuccess(Object object) {
Log.d("ObjectSync", "Object sync successful");
}

        @Override
        public void onFailure(Object error) {
            Log.e("ObjectSync", "Object sync failed with error: " + error);
        }
    },
    new VMXProgressCallback() {
        @Override
        public void onProgress(Object object) {
            Log.d("ObjectSync", "Object sync progress event received");
        }
    });

// Now attempt to Cancel Sync
syncObject.cancelSync(new HashMap < String, Object > (),
new VMXCallback() {
@Override
public void onSuccess(Object object) {
Log.d("ObjectSync Cancellation", "Object sync cancellation successful");
}

        @Override
        public void onFailure(Object error) {
            Log.e("ObjectSync Cancellation", "Object sync cancellation failed with error: " + error);
        }
    });

iOS (Objective C)

Signature

(void)cancelSync:(NSDictionary *)options
onSuccess:(VMXSuccessCompletionHandler)onSuccess
onFailure:(VMXFailureCompletionHandler)onFailure

Parameters

ParameterTypeDescriptionRequired
onSuccessVMXSuccessCompletionHandlerThe method called after a successful cancellation.Yes
onFailureVMXFailureCompletionHandlerThe method called after the cancellation fails.Yes

Return Type

void

Example

NSError * error;

VMXObj * syncObject = [
[VMXObj alloc] initWithName: @"Managers"
error: & error
];

// Define Sync options
NSMutableDictionary * syncOptions = [NSMutableDictionary new];
[syncOptions setObject: @"100"
forKey: @"downloadBatchSize"
];
[syncOptions setObject: @"200"
forKey: @"uploadBatchSize"
];
[syncOptions setObject: @"true"
forKey: @"getSyncStats"
];

// Start Sync asynchronously
[syncObject startSync: syncOptions
onSuccess: ^ (id object) {
NSLog(@"Object sync successful");
}   
onFailure: ^ (NSError * error) {
NSLog(@"Object sync failed with error: %@", [error description]);
}
onProgress: ^ (id object) {
NSLog(@"Object sync progress event received");
}
];

// Now attempt to Cancel Sync
// passing an empty dictionary for options parameter
NSMutableDictionary _ cancelSyncOptions = [NSMutableDictionary new];
[syncObject cancelSync: cancelSyncOptions
onSuccess: ^ (id object) {
NSLog(@"Object sync cancellation successful");
}
onFailure: ^ (NSError _ error) {
NSLog(@"Object sync cancellation failed with error: %@", [error description]);
}
];