简体   繁体   English

将GWT应用程序分解为模块,入口点和片段

[英]Decomposing GWT Application into Modules, Entry Points & Fragments

My understanding of a GWT module is that it is a "unit of reusability". GWT模块的理解是,它是“可重用性的单位”。

My understanding of an EntryPoint is that it is a module that is mean to interact with a client browser. EntryPoint 理解是,它是与客户端浏览器进行交互的模块。 Thus, I think of an EntryPoint as sort of an "executable JAR", and a module as a library JAR or DLL. 因此,我认为EntryPoint是一种“可执行JAR”,而模块是一个库JAR或DLL。

My understanding of a fragment is that it is a sub-component of a module used for the purposes of deferred binding and codesplitting. 片段的理解是,它是模块的子组件,用于延迟绑定和代码拆分。

So first, if I am incorrect on any of these assertions, please begin by correcting me or clarifying things for me! 因此,首先,如果我对以上任何说法都不正确,请首先纠正我或为我澄清事情!

If I am correct, then it is obvious that you decompose a module into fragment based on need . 如果我是正确的,那么很明显,您可以根据需要将模块分解为片段。 You write your module, you test it every which way, you review your soyc compiler reports, and if you see bottlenecks, you begin to fragment and codesplit as necessary, yes? 您编写模块,以各种方式对其进行测试,查看soyc编译器报告,如果发现瓶颈,则可以根据需要开始分段和代码拆分,是吗?

But how do you decompose an app into modules and entry points?!? 但是,如何将应用程序分解为模块和入口点呢?! Again, I'm sure it all comes down to need and is application-specific. 再次,我确定所有这些都是需要的并且是特定于应用程序的。 I just read this article on structuring a GWT app , and although it was quite helpful, it still didn't provide any litmus or set of guidelines for decomposing an app into modules/entry points. 我只是读了这篇有关构建GWT应用程序的文章 ,尽管它很有帮助,但它仍然没有提供将应用程序分解为模块/入口点的任何琐事或指导原则。

I am already planning on splitting my app into two modules: a WebModule and an AppModule . 我已经计划将我的应用程序分为两个模块: WebModuleAppModule The WebModule would be the "public" portion of the app (the website , if you will), and the AppModule will be downloaded after the user successfully logs in (I do this for security purposes). WebModule将成为应用程序( 网站 ,如果您愿意的话)的“公共”部分,并且在用户成功登录后将下载AppModule (出于安全目的,我这样做)。

But beyond that, I'm not really sure as to how to break my AppModule out into other modules , and how to determine whether or not those modules need entry points. 但是除此之外, 我不确定如何将AppModule分解为其他模块 ,以及如何确定这些模块是否需要入口点。 So I ask: if you fragment a module to circumvent network latency issues with the code download, when/why do you modularize an app, and when does a module need an entry point? 因此,我想问:您是否将模块拆分以通过代码下载来规避网络延迟问题,何时/为什么要对应用程序进行模块化,以及何时模块需要入口点?

EntryPoint is not a seperate module. EntryPoint不是单独的模块。 It is part of a module and has a function which will be invoked when the application is started. 它是模块的一部分,并具有在启动应用程序时将被调用的功能。

The point of modules is to group logical functionality so you can share code between different projects. 模块的重点是对逻辑功能进行分组,以便您可以在不同项目之间共享代码。 Nothing else. 没有其他的。 GWT already comes with a bunch of modules (HTTP, Activity, Places, Debug). GWT已经附带了很多模块(HTTP,Activity,Places,Debug)。 You may have a COMMENT or a USER module in your application if you decide to group it like that. 如果您决定像这样将其分组,则您的应用程序中可能包含一个COMMENT或USER模块。

Codesplitting should only be used where needed. 仅在需要时才使用代码拆分。 It can be a major annoyance that you can only reference code beyond fragment boundaries through the GWT.runAsync() . 您可能只能通过GWT.runAsync()引用超出片段边界的代码,这可能是一个很大的烦恼。 I suggest you only take this step if you experience your application being slow to load. 我建议您仅在遇到应用程序加载缓慢的情况下才执行此步骤。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM