本文介绍了GWT - 我应该在哪里使用code分裂,而使用的地方/活动/映射器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

芯是指在最初的片加载的应用的

"core" refers to the initial piece of the application that is loaded.


  • 为了绑定URL的地方,GWT使用 PlaceTokenizer< p延伸广场> 。当加载从URL的应用程序,它调用方法点getPlace(字符串标记)来检索调用的地方的新实例。

  • In order to bind url to places, GWT uses PlaceTokenizer<P extends Place>. When loading the application from the url, it calls the method P getPlace(String token) to retrieve a new instance of the place to call.

由于code分裂的异步性,我不能创造这种方法在 runAsync 的地方。所以,我必须把全部我的核心应用程序的地方。

due to the asynchronous nature of code splitting, I can't create the place inside a runAsync in this method. So I have to put all the places of my app in the core.

要链接的地方活动,GWT将活动getActivity(地点的地方)(从 com.google.gwt.activity.shared .ActivityMapper )来检索活动的新实例。

To link places to activity, GWT callsActivity getActivity(Place place) (from com.google.gwt.activity.shared.ActivityMapper) to retrieve a new instance of the activity.

再一次,我必须把全部我的活动的核心。

Once again, i have to put all my activities in the core.

下面是我想尝试什么:写一个自定义的 com.google.gwt.place.shared.Delegate

Here's what I want to try: Write a custom com.google.gwt.place.shared.Delegate that


    PlaceChangeRequestEvent
  • 绑定本身。如果未加载对应requestedPlace的AppPiece,它调用 event.setWarning(NEED_TO_LOAD_MODULE)

  • 确认(字符串消息)方法的总是返回假消息等于当 NEED_TO_LOAD_MODULE (所以它不会打扰用户),并通过 RunAsync 。

  • 一旦模块加载,请拨打 GOTO(requestedPlace)

  • bind itself on PlaceChangeRequestEvent. If the AppPiece corresponding to the requestedPlace isn't loaded, it calls event.setWarning(NEED_TO_LOAD_MODULE)
  • in the confirm(String message) method, always return false when the message equals NEED_TO_LOAD_MODULE (so it doesn't bother the user), and load the module via RunAsync.
  • Once the module is loaded, call goTo(requestedPlace)

我的应用程序的每个AppPiece包含了一堆activies和相应的意见。由于映射器只被调用时, PlaceChangeEvent 被激发,我可以生成我活动的新实例通过 AppPiece.getSomeActivityInstance()

Each AppPiece of my application contains a bunch of activies and the corresponding views. Since the mappers are only called when PlaceChangeEventis fired, i could generate a new instance of my activity via AppPiece.getSomeActivityInstance().

我是pretty肯定这会工作,但什么打扰我是

I'm pretty sure this will work, but what bother me is that


  • 查找至极AppPiece加载取决于requestedPlace会强迫我写code,这将是非常相似,我的映射器

  • 我想有我的相应AppPiece
  • 里面的地方
  • 重写代表用于此目的是棘手的,我正在寻找一个更好的解决方案

  • Finding wich AppPiece to load depending on the requestedPlace will force me to write code that will be very similar to my mappers
  • I would like to have my places inside the corresponding AppPiece
  • Overriding Delegate for this purpose is tricky, and I'm looking for a better solution

推荐答案

您不必把所有的活动的核心的(如你称呼它):当一个活动实例检索同步,它是允许的开始异步。这就是你把你的 GWT.runAsync 电话。

You don't have to put all your activities in the core (as you call it): while an Activity instance is retrieved synchronously, it's allowed to start asynchronously. This is where you'd put your GWT.runAsync call.

请参阅和https://groups.google.com/d/topic/google-web-toolkit/8_P_d4aT-0E/discussion

这篇关于GWT - 我应该在哪里使用code分裂,而使用的地方/活动/映射器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-30 07:27