code: public static <T> CompletionStage<T> doOnFxThread(final T element, final Consumer<T> action) {
          return CompletableFuture.supplyAsync(() -> {
              action.accept(element);
              return element;
          }, Platform::runLater);
      }
docs: Asynchronously executes a consuming operation on the JavaFX thread.
  
  @param element The element to consume
  @param action  How to consume it
  @param <T>     The type of the element consumed
  
  @return A {@link CompletionStage} to have monitoring over the state of the asynchronous operation.
  <p>
  Please make sure to read this class' documentation regarding threading and these methods.