Class PublicResourcesLiveUpdater
- All Implemented Interfaces:
Closeable,AutoCloseable
Watched source roots map to public static resources in the running application, such as:
- src/main/resources/META-INF/resources
- src/main/resources/resources
- src/main/resources/static
- src/main/resources/public
- src/main/webapp
For internal use only. May be renamed or removed in a future release.
- Since:
- 25.0
-
Constructor Summary
ConstructorsConstructorDescriptionPublicResourcesLiveUpdater(List<String> roots, VaadinContext context) Starts watching the given list of source folders for CSS changes. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()static intpush(VaadinContext context, List<File> extraRoots) Re-bundles every active@StyleSheetURL and pushes the result to the browser, which is what the watcher does when a public CSS file is saved.static voidsuspend(VaadinContext context) Stops this watcher from pushing CSS changes for the given context.
-
Constructor Details
-
PublicResourcesLiveUpdater
Starts watching the given list of source folders for CSS changes.- Parameters:
roots- the list of source folders to watch; non-existing ones are ignoredcontext- the current Vaadin context
-
-
Method Details
-
suspend
Stops this watcher from pushing CSS changes for the given context.For a tool that owns the edit-to-running-app loop, watching on save is the wrong trigger: the loop decides when a change goes live, and a second watcher pushing on its own makes "what is the state of my last change?" unanswerable. Such a tool suspends this and performs the resource leg itself.
A context attribute rather than a field, so it can be set before or after the watcher is created - the check happens when a file changes.
- Parameters:
context- the current Vaadin context- Since:
- 25.3
-
push
Re-bundles every active@StyleSheetURL and pushes the result to the browser, which is what the watcher does when a public CSS file is saved.Separate from the watcher so a tool that owns the apply loop can perform exactly the same update at the moment it decides a change goes live, rather than reimplementing the bundling and the URL. See
suspend(VaadinContext), andThemeLiveUpdater.push(java.io.File, com.vaadin.flow.server.VaadinContext)for the theme leg's equivalent.Every active URL rather than only the file that changed, because an
@importmeans the stylesheet the browser knows is not the file that was edited - and the URL the browser knows it by is what the update has to be keyed on.For internal use only. May be renamed or removed in a future release.
- Parameters:
context- the current Vaadin contextextraRoots- public resource roots to resolve against in addition to this project's own, for a caller that knows of roots this watcher does not - a reactor sibling's, say. Empty for the watcher itself.- Returns:
- how many stylesheets reached the browser
- Since:
- 25.3
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-