Package com.vaadin.base.devserver
Class ThemeLiveUpdater
java.lang.Object
com.vaadin.base.devserver.ThemeLiveUpdater
- All Implemented Interfaces:
Closeable,AutoCloseable
Watches the given theme folder for changes, combines the theme on changes and
pushes the new version to the browser.
- Since:
- 24.1
-
Constructor Summary
ConstructorsConstructorDescriptionThemeLiveUpdater(File themeFolder, com.vaadin.flow.server.VaadinContext context) Starts watching the given theme folder (containing styles.css). -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Stops watching the folder and cleans up resources.static booleanCombines the theme and pushes the new stylesheet to the browser, which is what the watcher does when a theme CSS file is saved.static voidsuspend(com.vaadin.flow.server.VaadinContext context) Stops this watcher from pushing on save, without stopping it.
-
Constructor Details
-
ThemeLiveUpdater
Starts watching the given theme folder (containing styles.css).- Parameters:
themeFolder- the folder to watchcontext- the current context
-
-
Method Details
-
push
Combines the theme and pushes the new stylesheet to the browser, which is what the watcher does when a theme 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 combining and the URL. See
suspend(VaadinContext).For internal use only. May be renamed or removed in a future release.
- Parameters:
themeFolder- the theme folder, whose name is the theme namecontext- the current context- Returns:
trueif the new stylesheet reached the browser- Since:
- 25.3
-
suspend
public static void suspend(com.vaadin.flow.server.VaadinContext context) Stops this watcher from pushing on save, without stopping it.A tool that owns the edit-to-running-app 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 theme update itself, through
push(File, VaadinContext).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
-
close
Stops watching the folder and cleans up resources.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-