Skip to content

Instantly share code, notes, and snippets.

@pyao-bwc
Created March 15, 2021 20:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pyao-bwc/8d14826f2d449a8fa1fb8c46207834e7 to your computer and use it in GitHub Desktop.
Save pyao-bwc/8d14826f2d449a8fa1fb8c46207834e7 to your computer and use it in GitHub Desktop.
Finalizer Deployment Issue
/**
* @description Promise implementation in apex, per:
* https://developer.salesforce.com/blogs/2020/01/learn-moar-in-spring-20-implementing-promises-with-transaction-finalizers.html
* Tested By: PromniseTest
*/
public abstract class Promise implements Queueable, Database.AllowsCallouts {
public List<Promise> promises = new List<Promise>();
public Object passThrough;
public Boolean continueChainAfterFailure = true;
protected Chain chain;
public Promise then(Object toAdd) {
promises.add((Promise) toAdd);
return this;
}
abstract public void execute();
public virtual void execute(QueueableContext context) {
chain = new Chain(this.promises, this.passThrough, this.continueChainAfterFailure);
System.attachFinalizer(chain);
execute();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment