public class ResourceLoader extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
ResourceLoader.ResourceLoadEvent
Event fired when a resource has been loaded.
|
static interface |
ResourceLoader.ResourceLoadListener
Event listener that gets notified when a resource has been loaded.
|
| Constructor and Description |
|---|
ResourceLoader(Registry registry,
boolean initFromDom)
Creates a new resource loader.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
addOnloadHandler(elemental.dom.Element element,
ResourceLoader.ResourceLoadListener listener,
ResourceLoader.ResourceLoadEvent event)
Adds an onload listener to the given element, which should be a link or a
script tag.
|
void |
inlineHtml(String htmlContents,
ResourceLoader.ResourceLoadListener resourceLoadListener)
Inlines an HTML import and notify a listener when the HTML import is
loaded.
|
void |
inlineScript(String scriptContents,
ResourceLoader.ResourceLoadListener resourceLoadListener)
Inlines a script and notify a listener when the script is loaded.
|
void |
inlineStyleSheet(String styleSheetContents,
ResourceLoader.ResourceLoadListener resourceLoadListener)
Inlines a stylesheet and notify a listener when the stylesheet is loaded.
|
void |
loadHtml(String htmlUrl,
ResourceLoader.ResourceLoadListener resourceLoadListener,
boolean async)
Loads an HTML import and notify a listener when the HTML import is
loaded.
|
void |
loadScript(String scriptUrl,
ResourceLoader.ResourceLoadListener resourceLoadListener)
Load a script and notify a listener when the script is loaded.
|
void |
loadScript(String scriptUrl,
ResourceLoader.ResourceLoadListener resourceLoadListener,
boolean async,
boolean defer)
Load a script and notify a listener when the script is loaded.
|
void |
loadStylesheet(String stylesheetUrl,
ResourceLoader.ResourceLoadListener resourceLoadListener)
Load a stylesheet and notify a listener when the stylesheet is loaded.
|
void |
runWhenHtmlImportsReady(Runnable task)
Sets the provided task to be run by
HTMLImports.whenReady. |
public ResourceLoader(Registry registry, boolean initFromDom)
Registry.getResourceLoader() to get an
instance.registry - the global registryinitFromDom - true if currently loaded resources should be
marked as loaded, false to ignore currently
loaded resourcespublic void loadScript(String scriptUrl, ResourceLoader.ResourceLoadListener resourceLoadListener)
Loads all dependencies with async = false and
defer = false attribute values, see
loadScript(String, ResourceLoadListener, boolean, boolean).
scriptUrl - the url of the script to loadresourceLoadListener - the listener that will get notified when the script is loadedpublic void loadScript(String scriptUrl, ResourceLoader.ResourceLoadListener resourceLoadListener, boolean async, boolean defer)
scriptUrl - url of script to loadresourceLoadListener - listener to notify when script is loadedasync - What mode the script.async attribute should be set todefer - What mode the script.defer attribute should be set topublic void inlineScript(String scriptContents, ResourceLoader.ResourceLoadListener resourceLoadListener)
scriptContents - the script contents to inlineresourceLoadListener - listener to notify when script is loadedpublic void loadHtml(String htmlUrl, ResourceLoader.ResourceLoadListener resourceLoadListener, boolean async)
htmlUrl - url of HTML import to loadresourceLoadListener - listener to notify when the HTML import is loadedasync - loads the import asynchronously, if true,
synchronously otherwisepublic void inlineHtml(String htmlContents, ResourceLoader.ResourceLoadListener resourceLoadListener)
htmlContents - the html contents to inlineresourceLoadListener - listener to notify when the HTML import is loadedpublic void runWhenHtmlImportsReady(Runnable task)
HTMLImports.whenReady.
The task is run immediately if HTMLImports.whenReady is not
supported.task - the task to run, not nullpublic static void addOnloadHandler(elemental.dom.Element element,
ResourceLoader.ResourceLoadListener listener,
ResourceLoader.ResourceLoadEvent event)
element - the element to attach a listener tolistener - the listener to callevent - the event passed to the listenerpublic void loadStylesheet(String stylesheetUrl, ResourceLoader.ResourceLoadListener resourceLoadListener)
stylesheetUrl - the url of the stylesheet to loadresourceLoadListener - the listener that will get notified when the stylesheet is
loadedpublic void inlineStyleSheet(String styleSheetContents, ResourceLoader.ResourceLoadListener resourceLoadListener)
styleSheetContents - the contents to inlineresourceLoadListener - the listener that will get notified when the stylesheet is
loadedCopyright © 2000–2018 Vaadin Ltd. All rights reserved.