Why use GWT.create() instead of new?

前端 未结 2 1990
南旧
南旧 2021-01-31 13:51

What is the difference between GWT.create(SomeClass.class) and new SomeClass()?

Why would you use one over the other?

2条回答
  •  -上瘾入骨i
    2021-01-31 14:41

    GWT.create is used by the GWT compiler for deferred binding. Deferred binding is a feature of the GWT compiler that works by generating many versions of code at compile time, only one of which needs to be loaded by a particular client during bootstrapping at runtime.

    You should only use the GWT.create for those cases that depend on this specific use case. For example when creating a RPC class: (MyServiceAsync)GWT.create(MyService.class). In all other cases use new.

    For more information check the GWT page on Deferred binding: http://code.google.com/webtoolkit/doc/latest/DevGuideCodingBasicsDeferred.html

提交回复
热议问题