pmonestie
unread,Jun 15, 2009, 4:53:56 PM6/15/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Google Web Toolkit
Hi,
I often export some of my gwt code as a Javascript library (using
timepedia exporter) so that my host page can use it as a 'simple' Js
library.
In the past I had issues waiting for the gwt module to load and I
always ended up writing a loop using setTimeout to wait for my gwt
module to startup.
Something like:
var loadCallbacks=[];
document.onload=gwtWait();
function gwtWait(){
if (typeof my_module== "undefined"){
setTimeout("gwtWait()", 500);
return;
}
for (i=0;i<loadCallbacks.length;i++){
loadCallbacks[i]();
}
}
loadCallbacks.push(function(){\
do_something with my module
}
I figured a way to modify the standard linker (IFrameLinker) to make
it accept callback function for when the module was loaded:
var funcHandler=[];
__MODULE_FUNC__.registerCallback=function (fName){
funcHandler.push(fName);
}
function notifyHandler(){
for (i=0;i<funcHandler.length;i++){
funcHandler[i]();
}
}
And in the function maybeStartModule() :
...
frameWnd.gwtOnLoad(onLoadErrorFunc, '__MODULE_NAME__', base);
notifyHandler();
So that in my host page I simply write:
my_module.registerCallback(function(){
...
}
Now I'm wondering:
Is this is the best way to do this?
Is there any way you guys could add something similar in the trunk?
It makes it easy to use gwt in a 'normal' html page
Thanks.