From c2e1cc5529815c30521ed948d7c292d678d59bc4 Mon Sep 17 00:00:00 2001 From: Yavor Georgiev Date: Thu, 8 Oct 2015 17:26:49 +0300 Subject: [PATCH] Async-ify decoding of image source http responses on iOS --- http/http-request.ios.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/http/http-request.ios.ts b/http/http-request.ios.ts index d01345506..101c25d14 100644 --- a/http/http-request.ios.ts +++ b/http/http-request.ios.ts @@ -65,6 +65,19 @@ export function request(options: http.HttpRequestOptions): Promise { + if (UIImage.imageWithData["async"]) { + return UIImage.imageWithData["async"](UIImage, [data]) + .then(image => { + if (!image) { + throw new Error("Response content may not be converted to an Image"); + } + + var source = new imageSource.ImageSource(); + source.setNativeSource(image); + return source; + }); + } + return new Promise((resolveImage, rejectImage) => { var img = imageSource.fromData(data); if (img instanceof imageSource.ImageSource) {