phonegap / phonegap-plugin-contentsync

Download and cache remotely hosted content
Apache License 2.0
206 stars 98 forks source link

`ContentSync.loadUrl` interface documentation doesn't reflect implementation. #155

Closed ttahmouch closed 7 years ago

ttahmouch commented 7 years ago

JavaScript implementation of ContentSync.loadUrl follows.

loadUrl: function(url, cb) {
    if(!url) {
        throw new Error('URL is required.');
    }
    exec(cb, cb, 'Sync', 'loadUrl', [url]);
}

Notice: A callback is passed to exec for success and failure.

Objective-C implementation of - (void)loadUrl:(CDVInvokedUrlCommand*) command follows.

- (void)loadUrl:(CDVInvokedUrlCommand*) command {
    NSString* url = [command argumentAtIndex:0 withDefault:nil];
    if(url != nil) {
        NSLog(@"Loading URL %@", url);
        NSURLRequest* request = [NSURLRequest requestWithURL:[NSURL URLWithString:url]];
        [self.webViewEngine loadRequest:request];
    } else {
        NSLog(@"URL IS NIL");
    }
}

Notice: A success or failure result, i.e., [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR ...] or [CDVPluginResult resultWithStatus:CDVCommandStatus_OK], is never returned.

However, the documentation allows for a callback function as shown here.