kweb-core
kweb-core copied to clipboard
Allow access to Gson type casting for `browser.evaluate` response
Basically, now that https://github.com/kwebio/kweb-core/issues/93 is fixed, it would be a nice API improvement to be able to use generics right up until the point where GSON casts the response to a JVM object, to be able to avoid getting the object through multiple castings and to specify some potential custom javascript return types.
Element currently has this:
/**
* Evaluate some JavaScript in the browser and return the result via a Future.
* This the foundation upon which most DOM-querying functions in this class
* are based.
*/
fun <O> evaluate(js: String, outputMapper: (Any) -> O): CompletableFuture<O>? {
return browser.evaluate(js).thenApply(outputMapper)
}
which is pretty close, but still first gets the response as Any rather than <T>
This is a fairly nitpicky issue, with some minor API gain, but would be a nice to have if it's not too much trouble
Potentially related to #59
Working on it in this here: https://github.com/kwebio/kweb-core/pull/96
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
Completed a while ago.