S
S
Seva2017-03-21 14:00:43
Grails
Seva, 2017-03-21 14:00:43

What's wrong with promises in Grails 3?

Hey!
Here is a simple example from the official documentation:

def test() {
      def map = new PromiseMap()
        map['one'] = { 2 * 2 }
        map['two'] = { 4 * 4 }
        map['three'] = { 8 * 8 }
        map.onComplete { Map results ->
          render results as JSON
        }
    }

The result is unpredictable and often wrong -
{"one":4,"two":16,"three":64}
Next run -
{"one":16,"two":64,"three":4}
What the fuck? Thank you.

Answer the question

In order to leave comments, you need to log in

Similar questions

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question