A node.js-like library providing Promise for Android
new Promise(handle -> {
// some work
// This is done in an async task
object value = ...;
handle.resolve(value);
}).then((value, handle) -> {
String upper = value.toString().toUpper();
handle.resolve(upper);
});
Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Then add the dependency
dependencies {
implementation 'com.github.emranbm:ePromise:1.2.0'
}
That's it!