Package com.vaadin.flow.dom.impl
Interface ElementJsInitializerRegistration.InitializerJs
- All Superinterfaces:
Serializable
- Enclosing class:
ElementJsInitializerRegistration
@JsDefinition
public static interface ElementJsInitializerRegistration.InitializerJs
extends Serializable
Runs and disposes of an initializer on the client, as a JavaScript
definition. Both calls run on the element of the registration.
For internal use only. May be renamed or removed in a future release.
-
Method Summary
Modifier and TypeMethodDescriptionvoiddispose(int initializerId) Calls the cleanup function that the initializer with the given id registered, if any.voidinit(int initializerId, JsFunction initializer) Applies the initializer to the element and registers the cleanup function it returns, to be called when the client discards the DOM node of the element or the initializer is disposed of.
-
Method Details
-
init
@JsExpression("const node = $executionContext.getNode(this);\nconst cleanup = $1.apply(this);\nif (typeof cleanup === \'function\') {\n $executionContext.registerInitializer(node, $0, cleanup);\n} else if (cleanup !== undefined && cleanup !== null) {\n console.error(\'addJsInitializer expression must return a function, null or undefined; got \' + (typeof cleanup));\n}\n") @JsWithExecutionContext void init(int initializerId, JsFunction initializer) Applies the initializer to the element and registers the cleanup function it returns, to be called when the client discards the DOM node of the element or the initializer is disposed of.- Parameters:
initializerId- the id of the initializer, unique within the UIinitializer- the initializer to apply
-
dispose
@JsExpression("try {\n $executionContext.disposeInitializer($executionContext.getNode(this), $0);\n} catch (e) {}\n") @JsWithExecutionContext void dispose(int initializerId) Calls the cleanup function that the initializer with the given id registered, if any.- Parameters:
initializerId- the id of the initializer
-