Posts

Showing posts with the label Asynchronous

Callout Limits For Future Methods And Queueable Apex

Image
Answer : I quickly wrote a class with future method to test this behaviour. public class FutureClassLimitsTest { @future(callout=true) public static void docallouts(){ for(Integer i=0;i<200;i++){ Http http=new Http(); HttpRequest hr=new HttpRequest(); hr.setMethod('POST'); hr.setEndpoint('https://google.com'); http.send(hr); } } } This is the error I get. First error: Too many callouts: 101. So I believe this is uniform for the whole platform irrespective of the transaction(Sync or Async). Is there a workaround? Well unless there is a strong business requirement it is kinda bad doing so many callous in a transaction. We can call a Queauble Method from Queueable method,.. and you can chain them infinitely. Thus using proper implementation you can have 100+ callouts. Batch is another way to tackle this. You have to write /modify data model add a some queue cus...

Angular / TypeScript - Call A Function After Another One Has Been Completed

Answer : So remove the setTimeout part. It will call resolve or reject and then pass the execution to the next then or catch handler. If you have some asynchronous call in the Promise, you need to call resolve/reject in the result of that call. What about not waiting 1500ms - the given time is actually the lowest time after which the function may be called. Maybe after 2000ms This is related to the main thread in which JS code works. If main thread has no work to done, then the results of the asynchronous calls are going to be executed. function f1() { return new Promise((resolve, reject) => { console.log('f1'); resolve(); }); } function f2() { console.log('f2'); } f1().then(res => f2()); If f1 is synchronous , there is nothing special to do: global() { f1(); f2(); } If f1 is asynchronous and return an Observable , use Rxjs operator , like concatMap: global() { f1().concatMap(() =>...