Domanda

I've just started a project built with the new GWT archetype.

ActivityMapper looks like:

public interface Factory {
    HomeActivity homeActivity();

    GreetingActivity greetingActivity(String user);
}

private final Factory factory;

@Inject
MainActivityMapper(Factory factory) {
    this.factory = factory;
}

@Override
public Activity getActivity(Place place) {
    if (place instanceof HomePlace) {
        return factory.homeActivity();
    }
    if (place instanceof GreetingPlace) {
        GreetingPlace greetingPlace = (GreetingPlace) place;
        return factory.greetingActivity(greetingPlace.getUser());
    }
    logger.severe("Unhandled place type: " + place.getClass().getName());
    return null;
}

I'm now trying to implement code split with AsyncProvider based on this example, but I can't get it working.

When using ActivityAsyncProxy, what should I do? return the ActivityAsyncProxy from getActivity(Place place)? but then, how can I create the ActivityAsyncProxy from the factory?

How would you suggest to make the activity mapper play nicely with code split?

È stato utile?

Soluzione

AFAICT, you cannot use AsyncProvider with assisted inject (that would be a great addition to GIN). That means you cannot benefit from generated runAsync calls, you'd have to do them yourself.

Have a look at http://code.google.com/p/google-web-toolkit/issues/detail?id=5129 for discussion of this issue, with several proposals.

Also have a look at https://groups.google.com/d/msg/google-web-toolkit-contributors/bUFYWEFskBI/ja2aJ0tBgdwJ for my own take on it (also available at https://gist.github.com/3038878).

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top