http://gwt-code-reviews.appspot.com/1386806/diff/1/user/src/com/google/gwt/activity/client/RunAsyncActivity.java
File user/src/com/google/gwt/activity/client/RunAsyncActivity.java
(right):
http://gwt-code-reviews.appspot.com/1386806/diff/1/user/src/com/google/gwt/activity/client/RunAsyncActivity.java#newcode66
user/src/com/google/gwt/activity/client/RunAsyncActivity.java:66:
GWT.runAsync(new RunAsyncCallback() {
Well hell, I think you're right.
I started on this patch because Antoine's
http://gwt-code-reviews.appspot.com/1383802/ seemed over-complex to me,
but I begin to see the issues he was facing.
Antoine, wouldn't your AbstractAsyncActivity have the same issue? I'm
not sure there is any way to automatically make split points without
resorting to code generation, probably via AsyncProxy
On 2011/03/25 01:53:05, tbroyer wrote:
I'm not used to GWT.runAsync but won't this create a single
split-point for all
provided activities, rather than a split-point for each of them (as it
would be
the case with AsyncProvider)?
If that's the case, I'd rather remove that overload and mandate an
AsyncProvider.
http://gwt-code-reviews.appspot.com/1386806/diff/1/user/src/com/google/gwt/activity/client/RunAsyncActivity.java#newcode87
user/src/com/google/gwt/activity/client/RunAsyncActivity.java:87:
wrapped.start(panel, eventBus);
On 2011/03/25 01:53:05, tbroyer wrote:
What if the activity is started, cancelled before it loads, and
started again?
Oops. I just plain forgot not to create the thing twice. Fixed it, and
the unit test is now watching it for it. Thanks again.
As coded here, it'll start twice. I guess GWT.runAsync takes care of
the ongoing
script load and doesn't try to load it twice; but that's not enough
here,
because the "cancel" call will be lost, and actually, the wrapped
activity from
the first onSuccess will be lost in "started" state.
Moreover, AsyncProvider might return a new Activity instance each time
it's
called, which makes it impossible to control the actually Activity
life-time
from the ActivityMapper (you might return the same RunAsyncActivity
instance,
but it doesn't mean you'll have a single instance of the wrapped
activity).
Shouldn't be an issue now that the provider only fires once.
I once started coding such an AsyncActivityWrapper but never actually
tested it.
I stored the panel and eventBus in fields and only async-loaded the
activity
once to make sure the callback is only called once; and I didn't
attempt to
async-load the activity if it was already loaded, or loading.
Something like:
if (loaded()) {
wrapped.start(panel,eventBus);
} else {
this.panel = panel;
this.eventBus = eventBus;
if (!loading()) { // only ever trigger a single async load
asyncProvider.get(...
public void onSuccess(Activity result) {
wrapped = result;
wrapped.start(RunAsyncActivity.this.panel,
RunAsyncActivity.this.eventBus);
}
...
});
loading = true;
}
As I said, I never actually tested my code, so maybe it's not worth
it...
http://gwt-code-reviews.appspot.com/1386806/diff/1/user/src/com/google/gwt/activity/client/RunAsyncActivity.java#newcode100
user/src/com/google/gwt/activity/client/RunAsyncActivity.java:100:
wrapped.onCancel();
On 2011/03/25 01:53:05, tbroyer wrote:
How about an 'else { cancelled = true; }' and in the onSuccess then
only call
the activity's start() if !cancelled?
Will do.
The same would have to be done in onStop() too (even though it
shouldn't ever
happen, because the activity shouldn't stopped if it hasn't yet "fully
started"
by calling the AcceptsOneWidget back)
No, that's pointless. onStop() is only called if start() returns.
(either a new boolean field or a specific value assigned to wrapped)
As coded here, if you cancel the activity before it's loaded, the
onSuccess will
start it anyway and the onCancel will be lost.
http://gwt-code-reviews.appspot.com/1386806/
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors