public static interface Fn.Presenter
META-INF/services
, for example with
@ServiceProvider(service = Fn.Presenter.class)
annotation.
To verify the implementation of the presenter is correct, implement
associated TCK (e.g. test compatibility kit) at least the headless
one as illustrated at:
public final class ScriptEngineJavaScriptTCK extendsSince 0.7 a presenter may implementJavaScriptTCK
{ static <R> void collectTckTests(List
<R> res,Function
<Method
, R> factory) { for (Class
c : testClasses()) { for (Method
m : c.getMethods()) { if (m.getAnnotation(KOTest
.class) != null) { res.add(factory.apply(m)); } } } } }
Executor
interface, in case
it supports single threaded execution environment. The executor's
Executor.execute(java.lang.Runnable)
method is then supposed
to invoke the runnable immediately (in case we are on the right thread
already) or return and asynchronously invoke the runnable later on the
right thread (if we are on wrong thread).Modifier and Type | Method and Description |
---|---|
Fn |
defineFn(java.lang.String code,
java.lang.String... names)
Creates new function with given parameter names and provided body.
|
void |
displayPage(java.net.URL page,
java.lang.Runnable onPageLoad)
Opens the browser, loads provided page and when the
page is ready, it calls back to the provider runnable.
|
void |
loadScript(java.io.Reader code)
Loads a script into the browser JavaScript interpreter and
executes it.
|
Fn defineFn(java.lang.String code, java.lang.String... names)
code
- the body of the function. Can refer to variables named
as names
names
- names of parameters of the function - these will be
available when the code
body executesvoid displayPage(java.net.URL page, java.lang.Runnable onPageLoad)
page
- the URL for the page to displayonPageLoad
- callback when the page is readyvoid loadScript(java.io.Reader code) throws java.lang.Exception
code
- the script to executejava.lang.Exception
- if something goes wrong, throw an exceptionCopyright © 2021 The Apache Software Foundation. All rights reserved.