use of com.vaadin.client.ResourceLoader.ResourceLoadEvent in project flow by vaadin.
the class AtmospherePushConnection method runWhenAtmosphereLoaded.
private void runWhenAtmosphereLoaded(final Command command) {
if (isAtmosphereLoaded()) {
command.execute();
} else {
final String pushJs = getVersionedPushJs();
Console.log("Loading " + pushJs);
ResourceLoader loader = registry.getResourceLoader();
String pushScriptUrl = registry.getApplicationConfiguration().getContextRootUrl() + pushJs;
ResourceLoadListener loadListener = new ResourceLoadListener() {
@Override
public void onLoad(ResourceLoadEvent event) {
if (isAtmosphereLoaded()) {
Console.log(pushJs + " loaded");
command.execute();
} else {
// If bootstrap tried to load
// vaadinPush.js, ResourceLoader assumes it succeeded
// even if it failed (#11673)
onError(event);
}
}
@Override
public void onError(ResourceLoadEvent event) {
getConnectionStateHandler().pushScriptLoadError(event.getResourceData());
}
};
loader.loadScript(pushScriptUrl, loadListener);
}
}
Aggregations