Created
April 12, 2016 18:59
-
-
Save glaforge/3ed5683039e9b78f826a6559937b106b to your computer and use it in GitHub Desktop.
Quick example of using JDeferred from Apache Groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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