Clean way in GWT/Java to wait for multiple asynchronous events to finish

前端 未结 8 883
盖世英雄少女心
盖世英雄少女心 2021-01-30 13:32

What is the best way to wait for multiple asynchronous callback functions to finish in Java before continuing. Specifically I\'m using GWT with AsyncCallback, but I think this i

8条回答
  •  暖寄归人
    2021-01-30 14:09

    Just tossing up some ideas:

    The callbacks fire some GwtEvent using the HandlerManager. The class containing the ready methods is registered with the HandlerManager as an EventHandler for the events fired by the callback methods, and holds the state (bookAPIAvailable, searchAPIAvailable, appLoaded).

    When a event arrives that specific state is changed, and we check if all the states are as desired.

    For an example using the GWTEvent, HandlerManager and EventHandler, see http://www.webspin.be/?p=5

提交回复
热议问题