javascript - Is there any in GWT to get notification about which fragment is going to be downloaded -
our gwt application has various fragments , each of them big in size(1+ mb). show progress bar when gwt downloading fragment. using gwtp based code splitting.
i not find related fragment loading event in gwt source code. have thought how javascript on page can notified fragment going downloaded next?
there not direct way, can workaround in 2 ways
1.- extending crosssiteiframelinker , overriding method getjsinstallscript() can homecoming customised javascript content alert somehow user permutation beingness loaded or show spinner. note script should contain code similar installscriptearlydownload.js or installscriptdirect.js
// linker class public class myxsilinker extends crosssiteiframelinker { @override protected string getjsinstallscript(linkercontext context) { homecoming "/your_namespace/your_script.js"; } } // "/your_namespace/your_script.js" script function installscript(filename) { } // module file <define-linker name="mylinker" class="...myxsilinker" /> <add-linker name="mylinker" /> 2.- using window.__gwtstatsevent function. can define function in index.html start loading spinner when script loading app going added document, utilize gwt code remove that.
// in index.html <head> <script> window.__gwtstatsevent = function(r) { if (r.type == 'scripttagadded') { d = document.createelement('div') d.id = 'loading' d.innerhtml = 'loading...' document.body.appendchild(d); } } </head> </script> // in entrypoint class document.get().getelementbyid("loading").removefromparent(); to show accurate progress-bar quite hard because <script> tag not back upwards progress events. best approach should linker loading permutation using ajax, can utilize html5 progress events in xhr object.
i utilize #2 approach showing nice spinner animated css.
javascript gwt
No comments:
Post a Comment