[TIMOB-24098] Windows: Async native function calls
GitHub Issue | n/a |
---|---|
Type | Improvement |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2017-04-11T13:41:49.000+0000 |
Affected Version/s | Release 5.4.0 |
Fix Version/s | Hyperloop 2.1.0 |
Components | Windows |
Labels | n/a |
Reporter | Kota Iguchi |
Assignee | Kota Iguchi |
Created | 2016-11-04T00:32:38.000+0000 |
Updated | 2017-04-19T01:42:05.000+0000 |
Description
Some of the WinRT APIs return asynchronous return types, such as
Windows.Foundation.IAsyncAction
. For methods that return an asynchronous return type, the operation need be wrapped in a [JavaScript Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) object.
var PathIO = require('Windows.Storage.PathIO');
PathIO.ReadTextAsync('ms-appdata:///somefile.txt').then(
function (content) {
alert(content);
},
function (err) {
alert('It failed!');
}
);
Validated fix with this environment: Node Version: 6.10.1 NPM Version: 4.4.4 Appc CLI: 6.2.0 Appc CLI NPM: 4.2.9 Titanium SDK version: 6.1.0v20170417190415 Appcelerator Studio, build: 4.8.1.201612050850 OS: Windows 10.0.14393 Targets: Windows 8.1 & 10 Devices. Windows 10 Emulator Hyperloop 2.1.0 I installed and executed the demo code that was presented in the PR. With the above emulator and devices, I was able to see the raw HTML content after clicking the button.