Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-28279] TiAPI: Return Promises for async APIs

GitHub Issuen/a
TypeEpic
PriorityMedium
StatusOpen
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labelsn/a
ReporterChristopher Williams
AssigneeChristopher Williams
Created2020-12-09T17:37:28.000+0000
Updated2021-08-26T11:04:14.000+0000

Description

We have a large number of APIs that take callbacks as arguments. Many can be modified to return a Promise. A few have been modified as part of the initial PR landing native Promise support. Landed: * Titanium.Android.requestPermissions * Titanium.Calendar.requestCalendarPermissions * Titanium.Contacts.requestContactsPermissions * Titanium.Database.DB.executeAsync * Titanium.Database.DB.executeAllAsync * Titanium.Filesystem.requestStoragePermissions * Titanium.Geolocation.getCurrentHeading * Titanium.Geolocation.getCurrentPosition * Titanium.Geolocation.requestLocationPermissions * Titanium.Geolocation.requestTemporaryFullAccuracyAuthorization * Titanium.Geolocation.forwardGeocoder * Titanium.Geolocation.reverseGeocoder * Titanium.Media.requestAudioRecorderPermissions * Titanium.Media.requestCameraPermissions * Titanium.Media.requestPhotoGalleryPermissions In Progress: * Titanium.UI.View.animate * Titanium.Media.Android.scanMediaFiles * Titanium.Media.requestMusicLibraryPermissions * Titanium.Media.takeScreenshot TODO: * Titanium.Android.Activity.startActivityForResult * Titanium.App.iOS.SearchableIndex.addToDefaultSearchableIndex * Titanium.App.iOS.SearchableIndex.deleteAllSearchableItems * Titanium.App.iOS.SearchableIndex.deleteAllSearchableItemByDomainIdenifiers * Titanium.App.iOS.SearchableIndex.deleteSearchableItemsByIdentifiers * Titanium.App.iOS.UserNotificationCenter.getPendingNotifications * Titanium.App.iOS.UserNotificationCenter.getDeliveredNotifications * Titanium.App.iOS.UserNotificationCenter.requestUserNotificationSettings * Titanium.Contacts.requestAuthorization * Titanium.Media.VideoPlayer.requestThumbnailImagesAtTimes * Titanium.Network.BonjourService.publish * Titanium.Network.BonjourService.resolve * Titanium.Network.BonjourService.stop * Titanium.Platform.openURL * Titanium.UI.WebView.takeSnapshot * Titanium.UI.WebView.createPDF * Titanium.UI.WebView.createWebArchive * Titanium.UI.WebView.findString Some return non-void types if the callback is omitted, however, so migrating them may prove to be more difficult. Async APIs that return values if callback is not supplied: * Titanium.UI.View.toImage * Titanium.UI.WebView.evalJS Additionally some APIs *do not* take a callback but occur async, return void, and could be made to return a Promise to that they are await-able. See TIMOB-27710 (i.e. Window.open())

Comments

  1. Ewan Harris 2021-08-26

    Converting to epic as this is a large chuck of work that won't be done in a single release Removed APIs the list that are no longer present in the SDK and updated in progress APIs

JSON Source