mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 11:42:04 +08:00
Snapshot refactorings, which mainly wraps Android extends within inner functions so that they are evaluated at runtime, when needed. Also some refactoring preventing circular requires.
This commit is contained in:
@ -12,12 +12,19 @@ import http = require("http");
|
||||
var requestIdCounter = 0;
|
||||
var pendingRequests = {};
|
||||
|
||||
var completeCallback = new com.tns.Async.CompleteCallback({
|
||||
onComplete: function (result: any, context: any) {
|
||||
// as a context we will receive the id of the request
|
||||
onRequestComplete(context, result);
|
||||
var completeCallback;
|
||||
function ensureCompleteCallback() {
|
||||
if (completeCallback) {
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
completeCallback = new com.tns.Async.CompleteCallback({
|
||||
onComplete: function (result: any, context: any) {
|
||||
// as a context we will receive the id of the request
|
||||
onRequestComplete(context, result);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function onRequestComplete(requestId: number, result: com.tns.Async.Http.RequestResult) {
|
||||
var callbacks = pendingRequests[requestId];
|
||||
@ -132,6 +139,7 @@ export function request(options: http.HttpRequestOptions): Promise<http.HttpResp
|
||||
};
|
||||
pendingRequests[requestIdCounter] = callbacks;
|
||||
|
||||
ensureCompleteCallback();
|
||||
//make the actual async call
|
||||
com.tns.Async.Http.MakeRequest(javaOptions, completeCallback, new java.lang.Integer(requestIdCounter));
|
||||
|
||||
|
Reference in New Issue
Block a user