开发者

How to remove a code that no more need on GWT?

Let's say I have a bunch of code that I need only once when application loads. For example initial data loading from the server. How do I remove this code? I mean not just remove Java objects but generated from it JavaScript code too. Is hugeHandler = null enough?

It's something opposite to 开发者_StackOverflow社区GWT.runAsync(), but "remove when don't need anymore" instead of "load when need".


You can use DOM.removeChild(Element parent, Element child) to remove a script tag from the . That will remove the javascript, and any created objects, and their references.

This is the difficult part :

You should also take care to split the code into two modules so you end up having 2 generated javascript files both of which you are including in the markup. One module (1st module) does the setup stuff, and the other module does the rest (2nd module).

I'm sure you have dependencies preventing you from splitting into two modules easily, but with some usage of JSNI native javascript methods in the second module, that, say, accesses variables created by the 1st module, you can potentially use all the setup done in the 1st module, and have no hard dependency at all.

I love the way GWT does not prevent you from writing your own javascript - but make sure that you don't lose cross browser compatibility when doing so.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜