gin と smartgwt でコード分割を使用する例を探しています ...
私の単純なアプリケーションには、2 つのモジュールAutoLoadModule
とWindowModule
. 私のシンプルなアプリでは、ボタンがクリックされたときにウィンドウをロードするだけです。
私のウィンドウモジュールには以下が含まれています:
@Override
protected void configure() {
bind(MainWindow.class).in(Singleton.class);
}
そして私のMainWindow
:
@Singleton
public class MainWindow extends Window implements SessionStatusChangedEvent.Handler {
private final XmppSession session;
@Inject
private MainWindow(XmppSession session) {
Log.debug("Constructor ImMainWindow... !");
this.session = session;
initComponent();
}
....................
私のAutoLoadModule
中で私はバインドしていますAutoLoad
asEagerSingleton();
@Override
protected void configure() {
bind(StartButton.class).toProvider(StartChatButtonProvider.class);
bind(AutoLoader.class).asEagerSingleton();
}
私AutoLoader
のクラス:
@Singleton
public class AutoLoader implements Scheduler.ScheduledCommand {
private final XmppConnection connection;
@Nullable
private final ImStartButton startButton;
@Inject
protected AutoLoader(final XmppConnection connection, final XmppSession session,
final StartButton startButton) {
this.startButton = startButton;
Scheduler.get().scheduleDeferred(this);
}
@Override
public final void execute() {
startButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
Log.debug("StartButton click handler...");
//load window in this point but how ? ....
}
});
}
}
ウィンドウがWindowModule
. 私のサンプルアプリでは、コード分割を使用してオンデマンドでのみウィンドウをロードする必要があり、そのウィンドウは gin モジュールにある必要があります。