2

i need to fire a function right after module is being loaded , as in right after onModuleLoad() execute what should i use to implement this thing , Timer or scheduleDeferred or anything else ?

something like
 
Scheduler.get().scheduleDeferred(new ScheduledCommand() {

            @Override
            public void execute() {
                Window.alert("bon jour! amis.");

            }
        });
     
or 
...
...

timer.schedule(2000);

or
??
  • 1
    What do you mean by "right after module is being loaded"? Is it when the view is fully initialized and rendered ? Is it after all async services launched on load are over ? For now I would say : use the scheduler, not the timer. – Naaooj Feb 03 '11 at 12:26
  • yes exactly , right after the view is fully initialized and rendered .. but scheduler is making loaded view and html unresponsive , while its loading other contents(Widgets) –  Feb 03 '11 at 12:45
  • 1
    According to the documentation, a deferred command is executed after the browser event loop returns. Unless widgets also use ScheduledCommand or load content asynchronously, your ScheduledCommand is not responsible of the unresponsiveness. – Naaooj Feb 03 '11 at 14:25
  • alright , thanks man , let me get back to you later. thanks again –  Feb 04 '11 at 05:09
  • @wingdings: Thanks to your question :) – sura2k Jan 02 '13 at 18:14

2 Answers2

3

Finding out when a GWT module has loaded might be helpful.

Community
  • 1
  • 1
z00bs
  • 7,518
  • 4
  • 34
  • 53
2

Use Scheduler.scheduleEntry in your EntryPoint implementation. I do this now to inject additional (non-GWT handled) stylesheets, and I need to ensure this happens after the view renders.

Valdis R
  • 2,095
  • 1
  • 18
  • 36
  • u mean like `Scheduler.get().scheduleEntry(new ScheduledCommand() {...});` it says in jdoc An "entry" command will be executed before GWT-generated code is invoked by the browser's event loop. This type of command is appropriate for code that needs to know when "something happens." whats browser event loop –  Feb 04 '11 at 05:18
  • problem with that is , its only loading when i hit the refresh button , as in its only executing commands when i hit the refresh button. –  Feb 04 '11 at 05:35
  • 1
    When you refresh, it'll re-load your EntryPoint, so onLoadModule() is invoked again. At the end of your onLoadModule(), invoke `Scheduler.get().scheduleEntry(new ScheduledCommand() {...});`. – Valdis R Feb 04 '11 at 14:31