如何集中"装载"屏幕GWT RPC? [英] how to centralize "loading" screen for GWT RPC?

查看:141
本文介绍了如何集中"装载"屏幕GWT RPC?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何集中为GWT异步RPC调用一个加载图标的管理?我正在寻找一种方式让每一个异步调用自动启动一个定时器。当计时器火灾,如果RPC尚未完成,应显示加载图标。当RPC完成时(无论是的onSuccess() onFailure处())的加载图标应该被删除。

How can I centralize management of a "loading" icon for GWT async RPC calls? I'm looking for a way to have every async call automatically kick off a timer. When the timer fires, if the RPC has not yet completed, a "loading" icon should be displayed. When the RPC completes (either onSuccess() or onFailure()) the loading icon should be removed.

这是乏味的每个呼叫手动做到这一点,其实很容易得到它错了,留给用户一个卡住UI。

It's tedious to do this manually for each call, and in fact quite easy to get it wrong and leave the user with a stuck UI.

能发电机使用这个?只是要在清我不是找code来显示一个对话框或图标;这样的对话/图标我正在寻找一种方法来集中的管理

Could generators be used for this? Just to be clear- I'm not looking for code to display a dialog or icon; I'm looking for a way to centralize management of such a dialog/icon.

推荐答案

也许我看它在一个更简单的方法。但是,我们有类似的行为在我们的应用中,我们只是使用Decorator模式实现它。装饰负责显示加载UI(在我们的例子就说明马上),并在返回时将确保UI再次删除。

Maybe I look at it in a more simple way. But we have similar behavior in our applications and we just implement it using a decorator pattern. The decorator takes care of showing the loading UI (in our case it shows right away), and on return makes sure that the UI is removed again.

我们的调用看起来有点像这样:

Our invocations look a bit like this:

rpc.dosomething( params, Modality.appModal( new AsyncCallback<String>() {
  public void onSuccess( String pValues ) {
    ... handle success ...
  }

  public void onFailure( Throwable pCause) {
    ... handle failure ....
  }
}));

Modality.appModal返回,做用户界面的一部分,之后成功或失败的调度给定作为调用参数的AsyncCallback一个AsyncCallback。

Modality.appModal returns an AsyncCallback that does the UI part and after success or failure dispatches to the AsyncCallback given as parameter in the invocation.

是否值得用code发电机进一步走向何方?它是实现一次,到处使用没有进一步的思考。

Is it worth going further with code generators ? It is implemented once and used everywhere without further thinking.

大卫

这篇关于如何集中&QUOT;装载&QUOT;屏幕GWT RPC?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆