Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Quick example of using JDeferred from Apache Groovy
@Grab('org.jdeferred:jdeferred-core:1.2.4')
import org.jdeferred.*
import org.jdeferred.impl.*
def deferred = new DeferredObject()
def promise = deferred.promise()
promise.done { result ->
println "done: $result"
}.fail { rejection ->
println "fail: $rejection"
}.always { state, result, rejection ->
println "always"
}
deferred.resolve("done")
//deferred.reject("oops")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment