[TIMOB-24549] TiAPI: Add support for Promises
GitHub Issue | n/a |
---|---|
Type | Epic |
Priority | High |
Status | Resolved |
Resolution | Fixed |
Resolution Date | 2020-12-09T17:25:05.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 10.0.0 |
Components | Android, iOS, Windows, Windows phone |
Labels | n/a |
Reporter | Hans Knöchel |
Assignee | Christopher Williams |
Created | 2017-04-01T19:01:59.000+0000 |
Updated | 2021-08-26T11:01:37.000+0000 |
Description
"The modern development world is highly asynchronous".
I agree, so we should add support for promises that can be used from the JS world to improve the general callback structure. On the native side, we should a new class "TiPromise" that can be used in the SDK, native modules and Hyperloop to allow promises.
I am not completely sure about the architecture so far, but we should definitely talk about it!
+1 for replacing all callback-based functions with Promise-based signatures, but this is such a major change that I think we should tackle this when we tackle Alloy v2.
This issue is resolved by TIMOB-24610
I think this issue should be reopened, because it was not about general
Promise
support (native or polyfills). It was about promise-based APIs vs callback-based, currently we still can not create native method which will return Promise to js side, all we have is old-school callback. -I have prepared POC for creating promise-based APIs for Android native modules:- * -[Branch](https://github.com/drauggres/titanium_mobile/commits/feature/promise-api)- * -[Builds](https://github.com/drauggres/titanium_mobile/releases/tag/v8.0.0.promise-preview)- -This is justproof-of-concept
so I will not create PR from it (but feel free to use it if you'll find it worth).- -P.S. I don't thinkpermissionRequest
should reject Promise that was done only to show both resolving and rejection.- ---- I rethought everything above and cleaned up code: https://github.com/appcelerator/titanium_mobile/pull/10554+1. While I would rather like to see full async/await support, this is a good step in that direction!
Re-opening as the "duplicate" ticket doesn't actually resolve this.
https://github.com/appcelerator/titanium_mobile/pull/10554
merged to master for 10.0.0 target Note that QE did not formally FR this yet, but the test suite was modified to include some tests for a couple new Promise-based APIs