diff --git a/flow-server/src/main/java/com/vaadin/flow/component/UI.java b/flow-server/src/main/java/com/vaadin/flow/component/UI.java
index 5f1dd534204..4d81602c761 100644
--- a/flow-server/src/main/java/com/vaadin/flow/component/UI.java
+++ b/flow-server/src/main/java/com/vaadin/flow/component/UI.java
@@ -629,9 +629,69 @@ public void handleError(Exception exception) {
* null
as described above
* @return a runnable that will run either the access task or the detach
* handler, possibly asynchronously
+ * @deprecated Use
+ * {@link #wrapWithAccess(SerializableRunnable, SerializableRunnable)}
+ * instead which is a better name for the method
+ *
*/
+ @Deprecated(forRemoval = true)
public SerializableRunnable accessLater(SerializableRunnable accessTask,
SerializableRunnable detachHandler) {
+ return wrapWithAccess(accessTask, detachHandler);
+ }
+
+ /**
+ * Wraps the given access task as a consumer that passes a value to the
+ * given task with this UI locked. The wrapped task may be run synchronously
+ * or asynchronously. If the UI is detached when the returned consumer is
+ * run, the provided detach handler is run instead. If the provided detach
+ * handler is null
, the returned runnable may throw an
+ * {@link UIDetachedException}.
+ *
+ * This method can be used to create a callback that can be passed to an
+ * external notifier that isn't aware of the synchronization needed to
+ * update a UI instance.
+ *
+ * @param accessTask
+ * the task that updates this UI, not
+ * This method can be used to create a callback that can be passed to an
+ * external notifier that isn't aware of the synchronization needed to
+ * update a UI instance.
+ *
+ * @param accessTask
+ * the task that updates this UI, not null
+ * @param detachHandler
+ * the callback that will be invoked if the UI is detached, or
+ * null
as described above
+ * @return a consumer that will run either the access task or the detach
+ * handler, possibly asynchronously
+ * @deprecated Use
+ * {@link #wrapWithAccess(SerializableConsumer, SerializableRunnable)}
+ * instead which is a better name for the method
+ */
+ @Deprecated(forRemoval = true)
+ public null
, the returned runnable may throw an
+ * {@link UIDetachedException}.
+ * null
+ * @param detachHandler
+ * the callback that will be invoked if the UI is detached, or
+ * null
as described above
+ * @return a runnable that will run either the access task or the detach
+ * handler, possibly asynchronously
+ */
+ public SerializableRunnable wrapWithAccess(SerializableRunnable accessTask,
+ SerializableRunnable detachHandler) {
Objects.requireNonNull(accessTask, "Access task cannot be null");
return () -> access(accessTask::run, detachHandler);
@@ -657,7 +717,7 @@ public SerializableRunnable accessLater(SerializableRunnable accessTask,
* @return a consumer that will run either the access task or the detach
* handler, possibly asynchronously
*/
- public