010-68421378
sales@cogitosoft.com
Your location:Home>News Center >New release

Delphi Promises Now in TMS FNC Cloud Pack

latest update:2025/03/24 Views:30
If youve worked with cloud APIs, you know the strugglewaiting for responses, handling event callbacks, and making sure e...

If you've worked with cloud APIs, you know the struggle—waiting for responses, handling event callbacks, and making sure each request happens in the right order. Things can quickly get messy, especially when multiple actions depend on each other.

 

To improve this, we introduced Promises in TMS FNC Core a while ago. Now, we're excited to bring Promise support directly into TMS FNC Cloud Pack! Instead of managing event handlers, Promises let you write clear, sequential code that’s easier to read and maintain.

 

What’s the Problem with Events?

Event-driven programming works, but it can lead to scattered logic. Take this example, where we fetch a folder list:

view plain text

Most often these 2 pieces of code will be far apart, which is harder to oversee. On top of that, the OnGetFolderList event will trigger each time GetFolderList is called, making it almost impossible to implement custom logic for separate GetFolderList calls.

 

How Promises Make It Simpler

With Promises, you chain operations together, keeping everything in one place:

view plain text

Now the logic is clear: Get the folder list, then update the UI—all in one place, without scattered event handlers.

 

A Real-Life Example: Access Token Renewal

When integrating Promises, we carefully evaluate where they bring the most value. One key area we identified is access token renewal. Tokens with shorter lifetimes can expire while you're working on something, causing requests to fail unexpectedly. Without Promises, handling renewals requires additional checks, event handlers, and retry logic.

 

To solve this, we introduced FetchAccessToken in TTMSFNCCloudOAuth. This means all descendant components automatically benefit from this improvement!

 

Calling FetchAccessToken returns a string with the latest valid access token. If the token is expired, it automatically retrieves a new one using the refresh token—all in a single call! Usage is as simple as:

view plain text

Or if you prefer Await:

view plain text

 

Try It Today!

As a first step, we integrated promises into a selection of most-used services. These are:

 

Update to the latest version and take your cloud-powered applications to the next level! Have any questions, remarks or need further assistance? Feel free to reach out and don't forget to check our feature request page if you need Promises support for other cloud services.

Next:RadView--WebLOAD vs. LoadRunner Which Tool is Right for You?
Prev:Ready to Rock: What’s New in Log Server 2024R2

© Copyright 2000-2023  COGITO SOFTWARE CO.,LTD. All rights reserved