2014년 9월 23일 화요일

javascript callback with argument

/**

ip 셋팅
id 셋팅

*/

//var jsdom = require("jsdom");
$ = require("jquery");

console.log("Hello world!");
JsTr = function(JsTr,$,undefined){
JsTr.cmd = "";
JsTr.getIpWrap = function(json,callback){
console.log("[JsTr.getIpWrap][assign][start]");
return (function(){
console.log("[JsTr.getIpWrap][run][start]");
getIp(json,callback);
console.log("[JsTr.getIpWrap][run][end]");
});
};

JsTr.getIdWrap = function(json,callback){
console.log("[JsTr.getIdWrap][assign][start]");
return (function(){
console.log("[JsTr.getIdWrap][run][start]");
getId(json,callback);
console.log("[JsTr.getIdWrap][run][end]");
});
};
var ip = "";
var id = "";
JsTr.send = function(serviceId,jsonParam,scb,fcb){
console.log("[JsTr.send][assign][start]");
// 콜백은 역순으로 만들면 된다.

var fRef_getIdWrap = JsTr.getIdWrap(jsonParam,scb,fcb);
var fRef_getIpWrap = JsTr.getIpWrap(jsonParam,fRef_getIdWrap);
//jsonParam += serviceId;
fRef_getIpWrap();
//
};

return JsTr;
}({},$);
JsTr.send("ttttttttttt",'{jsonParam:11}',successCallBack);
function getIp(json,callback){
console.log("[getIp][run][start]");
JsTr.cmd += ",ip:123.22.55.101";
callback();
console.log("[getIp][run][end]"+json);
}
function getId(json,callback){
console.log("[getId][run][start]");
JsTr.cmd += ",id:130.204.77";
callback(JsTr.cmd);
console.log("[getId][run][end]"+json);
}


function successCallBack(ret){
console.log("[successCallBack][run][start]");
console.log(ret);
console.log("[successCallBack][run][end]");
}
function failCallBack(ret){
console.log("[failCallBack][run][start]");
console.log(ret);
console.log("[failCallBack][run][end]");
}

// ref :// http://directwebremoting.org/dwr/documentation/browser/extra-data.html

댓글 없음:

댓글 쓰기

eclipse rcp dialog resize

  Dialog 안에 메소드를 만든다. private void autoResize(){     getShell().layout( true, true);     final Point newSize = getShell().computeSize...