kweb-core icon indicating copy to clipboard operation
kweb-core copied to clipboard

Allow access to Gson type casting for `browser.evaluate` response

Open alkoclick opened this issue 5 years ago • 2 comments

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

alkoclick avatar Jan 26 '20 19:01 alkoclick

Potentially related to #59

alkoclick avatar Jan 26 '20 19:01 alkoclick

Working on it in this here: https://github.com/kwebio/kweb-core/pull/96

sanity avatar Jan 27 '20 16:01 sanity

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.

github-actions[bot] avatar Oct 13 '22 03:10 github-actions[bot]

Completed a while ago.

sanity avatar Oct 13 '22 06:10 sanity