如何在Mono.subscribe中使用UI.getCurrent()。navigate(“ route”)

问题描述 投票:0回答:1
  public void onAlfrescoTicketReceived(Mono<Ticket> ticket) {
    ticket
        .log()
        .subscribe(
            consumer -> {
              this.sessionService.setTicket(consumer.getTicket());
              UI.getCurrent().navigate("route");
            });
  }

sessionService有效,但UI.getCurrent返回null。有没有一种方法可以在订阅中导航?

java vaadin webclient vaadin-flow
1个回答
1
投票

它可能在后台线程中执行。 UI.getCurrent()仅在UI线程中起作用。

© www.soinside.com 2019 - 2024. All rights reserved.