0

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

Kias
  • 841
  • 9
  • 22

1 Answers1

0

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();
           }
        }
    };
}
Maxim Fateev
  • 6,458
  • 3
  • 20
  • 35
  • I see, so basically just nest any branches in to separate methods. I'll give it a go and report back. – Kias Jul 28 '14 at 18:22