Promises support
Promise-based methods let Cloud Pack applications sequence asynchronous service calls without spreading dependent work across many event handlers.
This guide focuses on the promise methods exposed by TMS FNC Cloud Pack components. For general Delphi promise concepts, see the Delphi-Promises documentation.
Events and promises
Event handlers work well when each request is independent. When one request depends on another, promise chains keep the order close to the code that starts the workflow. This is useful for storage services, Gmail, Outlook, and Stellar Data Store operations where an access token may need to be refreshed before the request executes.
Result locations
Promise methods return a managed promise value and update the same component state that event-based calls update. The method name usually indicates where to read the result.
| Promise method | Result location |
|---|---|
TTMSFNCCloudGoogleGmail.GetLabelsPromise |
TTMSFNCCloudGoogleGmail.Labels |
TTMSFNCCloudGoogleDrive.GetAccountInfoPromise |
TTMSFNCCloudGoogleDrive.Info |
TTMSFNCCloudGoogleDrive.GetAttachmentPromise(AAttachment) |
The supplied attachment object. |
GetFolderListPromise on storage services |
PromiseFolderList |
GetFolderListHierarchicalPromise on storage services |
PromiseFolderList |
Search*Promise on storage services |
PromiseSearch |
CreateFolderPromise on storage services |
PromiseCreateFolder |
GetFileInfoPromise and GetFolderInfoPromise on Box, DropBox, and Google Drive |
PromiseFileInfo |
InsertPromise(AEntities) on Stellar Data Store |
PromiseInsertEntities |
Fetching an access token
Components that inherit from TTMSFNCCloudOAuth expose FetchAccessToken: IPromise<string>. Use it when a workflow needs a valid access token before a later request. If the access token has expired, the component attempts to refresh it with the stored refresh token; if the refresh token is missing or invalid, the OAuth authorization process is started again.