Class TimeoutTrigger
java.lang.Object
com.vaadin.flow.component.trigger.internal.Trigger
com.vaadin.flow.component.trigger.internal.TimeoutTrigger
- All Implemented Interfaces:
Serializable
Fires once, on the client, after the given delay has elapsed. The delay is
measured by the browser via a single
setTimeout armed when the host
is initialized on the client; when it elapses the bound actions run. Pair it
with a value-less CallbackAction (or any other action) to run
server-side work a short while later without enabling push.
Unlike event- or observer-based triggers, this one fires a single time. The
timer is cleared if the trigger is removed before it
elapses; because it lives in the browser, it also never fires if the host's
client DOM goes away (page reload, navigation, ?) first.
For internal use only. May be renamed or removed in a future release.
- Since:
- 25.2
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionTimeoutTrigger(Component host, Duration delay) Creates a trigger that fires once, the given delay after the host is initialized on the client. -
Method Summary
Modifier and TypeMethodDescriptionprotected Registrationinstall(JsFunction action) Installs the given rendered action as a client-side listener and returns theRegistrationthat detaches it.
-
Constructor Details
-
TimeoutTrigger
Creates a trigger that fires once, the given delay after the host is initialized on the client.- Parameters:
host- the component whose client-side initialization arms the timer, notnulldelay- how long to wait before firing, notnulland not negative
-
-
Method Details
-
install
Description copied from class:TriggerInstalls the given rendered action as a client-side listener and returns theRegistrationthat detaches it. Called once per action passed toTrigger.triggers(Action...).Implementations typically call
getHost().addJsInitializerwith an install expression that hands the actionJsFunctionto whatever client API the trigger wraps:
The expression runs withreturn getHost().addJsInitializer( "this.addEventListener($1, $0);" + "return () => this.removeEventListener($1, $0);", action, eventName);thisbound to the host element. The captures are made available as$0,$1, ? in the order passed.- Specified by:
installin classTrigger- Parameters:
action- the rendered actionJsFunction; takes one runtime argument namedevent(the trigger's event payload), notnull- Returns:
- the registration whose
Registration.remove()detaches the listener, notnull
-