I think my question has a straight forward answer, I just can't seem to find it.
I have a basic workflow:
private void doWorkflow() {
Promise<Boolean> result = activityClient.checkSomething();
if (result.get() == true) {
//exit
}
activityClient.doSomething();
}
The first problem is I cannot seem to get the result within the workflow. I have to go to an @asynchronous method to get the result. Secondly, if I were to use an @asynchronous method to determine if I should exit early then I'm back to square one since @asynchronous methods need to return a promise.
Thanks in advance
I would rewrite your code as:
private void doWorkflow() {
Promise<Boolean> result = activityClient.checkSomething();
doSomething(result);
}
@Asynchronous
private void doSomething(Promise<Boolean> flag) {
if (!flag.get()) {
activityClient.doSomething();
}
}
If you don't want to use @Asynchronous method you can use Task directly:
private void doWorkflow() {
final Promise<Boolean> result = activityClient.checkSomething();
new Task(result) {
public void do Execute() {
if (!result.get()) {
activityClient.doSomething();
}
}
};
}