Introducing Long-Running Callouts with Continuations!
Are you looking for a better way to manage callouts in your Apex code?
With the Continuation class, you can make long-running requests to external web services and drastically improve the user experience in your app.
Here are some key advantages of using continuations:
1. Parallel Callouts:
Continuations allow you to make callouts in parallel, improving the efficiency of your code and reducing the response time.
This means you can retrieve multiple sets of data simultaneously, enhancing the speed and performance of your application.
2. Transparent Batching:
The framework intelligently queues up actions and minimizes network traffic by batching multiple actions into a single request.
This "boxcar'ing" mechanism optimizes performance and reduces the number of round trips to the server, resulting in faster data retrieval and a smoother user experience.
3. Background Processing:
Since continuations can be long-running requests, they are treated as background actions by the framework.
This means they won't block other actions while running, allowing your app to remain responsive and providing a seamless user experience.
Users can continue to interact with the app while the long-running callouts are processed behind the scenes.
4. No Limit Impact:
As of Winter '20, all callouts, including asynchronous ones made with continuations, are excluded from the long-running request limit.
This eliminates any concerns about hitting limits and allows you to confidently implement long-running callouts without worrying about impacting other aspects of your code.
To start using continuations, simply import Apex methods from "@salesforce/apexContinuation".
This convenient syntax will give you access to the necessary Apex methods for your project, making it easy to incorporate continuations into your existing codebase.
// Syntax
import apexMethodName from "@salesforce/apexContinuation/Namespace.Classname.apexMethodName";
// Example
import startRequest from "@salesforce/apexContinuation/SampleContinuationClass.startRequest";
apexMethodName—A symbol that identifies the Apex method.
apexMethodReference—The name of the Apex method to import.
Classname—The name of the Apex class.
Namespace—If the class is in the same namespace as the component, don’t specify a namespace.
If the class is in a managed package, specify the namespace of the managed package.
Follow Us