index.js
function executeApiCall(callback, needConnection) {
        needConnection = typeof needConnection !== 'undefined' ? needConnection : true;
        authenticate(function (error, result) {
            if (error || !result) {
                callback(error, result);
                return;
            }
            if (needConnection) {
                isConnected(function (error, result) {
                    if (error || !result) {
                        console.error("[Deluge] WebUI not connected to a daemon");
                        return;
                    }
                    callback(error, result);
                });
            } else {
                callback(error, result);
            }
        });
    }
function executeApiCall(callback, needConnection) {
        needConnection = typeof needConnection !== 'undefined' ? needConnection : true;
        authenticate(function (error, result) {
            if (error || !result) {
                callback(error, result);
                return;
            }
            if (needConnection) {
                isConnected(function (error, result) {
                    if (error || !result) {
                        console.error("[Deluge] WebUI not connected to a daemon");
                        return;
                    }
                    callback(error, result);
                });
            } else {
                callback(error, result);
            }
        });
    }
function executeApiCall ( callback , needConnection ) { needConnection = typeof needConnection !== 'undefined' ? needConnection : true ; authenticate ( function ( error , result ) { if ( error || ! result ) { callback ( error , result ) ; return ; } if ( needConnection ) { isConnected ( function ( error , result ) { if ( error || ! result ) { console . error ( "[Deluge] WebUI not connected to a daemon" ) ; return ; } callback ( error , result ) ; } ) ; } else { callback ( error , result ) ; } } ) ; }
Connect if not connected then execute the callback method
@param callback
Connect if not connected then execute the callback method