I am trying to call an Android native function "refreshPages" from JS function "refreshPagesWithIds" which passes an array of strings to native.
id: ["1","2"];
refreshPagesWithIds(id) {
return Android.refreshPages(id);
}
The Android native function "refreshPages" internally calls a method "someFunction" which takes id array as argument and returns a Promise after refreshing the pages.
@JavascriptInterface
public void refreshPages(String[] ids) {
StorageModule.someFunction(ids, null);
}
someFunction looks like:
@JvmStatic
fun someFunction(pageIds: ReadableArray, promise: Promise? = null) {
val storagePromise = StoragePromise(promise, storageModules.size)
storageModules.forEach { module -> module.refreshPagesWithIds(pageIds, storagePromise) }
}
How can I return a value when the Promise from refreshPages function(in native) gets settled to Javascript? I am unable to understand the implementation for public void refreshPages(String[] ids)