From e6d9c7aab3b5c750c6ece173c1e1531ade8f2fa7 Mon Sep 17 00:00:00 2001 From: Joshua Granick Date: Mon, 20 Mar 2017 14:59:58 -0700 Subject: [PATCH] HTTPRequest thread fix --- lime/_backend/native/NativeHTTPRequest.hx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lime/_backend/native/NativeHTTPRequest.hx b/lime/_backend/native/NativeHTTPRequest.hx index 62c8dde2a..fc25f242a 100644 --- a/lime/_backend/native/NativeHTTPRequest.hx +++ b/lime/_backend/native/NativeHTTPRequest.hx @@ -100,7 +100,7 @@ class NativeHTTPRequest { if (path == null #if (sys && !android) || !FileSystem.exists (path) #end) { - promise.error ("Cannot load file: " + path); + worker.sendError ("Cannot load file: " + path); } else { @@ -108,16 +108,26 @@ class NativeHTTPRequest { if (bytes != null) { - promise.complete (bytes); + worker.sendComplete (bytes); } else { - promise.error ("Cannot load file: " + path); + worker.sendError ("Cannot load file: " + path); } } + }); + worker.onComplete.add (function (result) { + + promise.complete (result); + + }); + worker.onError.add (function (message) { + + promise.error (message); + }); worker.run ();