Class BeforeClientResponseAction
- All Implemented Interfaces:
Serializable
Use this to defer an update to the end of the round trip, for example when several changes in the same round trip affect the same client-side state and the update should only run once, with the final state. Scheduling the action again before it has run has no effect, and you can cancel a scheduled action.
Compared to registering the action directly with
UI.beforeClientResponse(com.vaadin.flow.component.Component, com.vaadin.flow.function.SerializableConsumer<com.vaadin.flow.internal.ExecutionContext>), the action also runs if the component is
detached and attached again before the response, also to a different UI.
For internal use only. May be renamed or removed in a future release.
- Since:
- 25.4
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionBeforeClientResponseAction(com.vaadin.flow.component.Component component, com.vaadin.flow.function.SerializableRunnable action) Creates a new action for the given component. -
Method Summary
-
Constructor Details
-
BeforeClientResponseAction
public BeforeClientResponseAction(com.vaadin.flow.component.Component component, com.vaadin.flow.function.SerializableRunnable action) Creates a new action for the given component. The action is not scheduled until you callschedule().If the action is a lambda or a method reference, do not store it in another field and do not capture it in another lambda. Otherwise the component can fail to deserialize.
- Parameters:
component- the component whose client response the action runs before, notnullaction- the action to run, notnull
-
-
Method Details
-
schedule
public void schedule()Schedules the action to run before the next client response while the component is attached. If the component is not attached, the action runs before the first response after the component has been attached. Does nothing if the action is already scheduled.The action only runs while the component is attached.
-
cancel
public void cancel()Cancels the scheduled action. Does nothing if the action is not scheduled.
-