Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Another example combining JDeferred with Groovy
@Grab('org.jdeferred:jdeferred-core:1.2.4')
import org.jdeferred.*
import org.jdeferred.impl.*
def d = new DeferredObject()
def p = d.promise()
// gotta be explicit and can't use Groovy closures:
// DoneCallback / DoneFilter / DonePite are ambiguous
// in terms of signature, for SAM type coercion
def filtered = p.then(new DoneFilter<Integer, Integer>() {
Integer filterDone(Integer result) {
result * 10
}
}).done { result ->
// result would be original * 10
assert result == 30
}
d.resolve(3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment