enhancement
major
minor
defect
critical
major
minor
major
#30088
View layer: document how a ChannelSource keeps a monitor running while its view is hidden and ends it with the window
Follow-up of #29814 and #29869, observed with 8.0.0-alpha12 in E-Home (haumacher/ehome, group monitor projects/monitor.view.xml, de.haumacher.ehome.monitor.MonitorSource).
A <source-channel> subscribes its ChannelSource only while the view declaring it is displayed; hiding the view (another tab selected) ends the subscription. Some sources must keep something running while the view is hidden: a KNX group monitor that records the bus, or a database monitor that records the queries of the application (as the monitor of the classic UI did, started and stopped from its view), so that the full log is shown when the tab is displayed again. Such a source needs to know when the recording is to end at the latest: when the window is torn down (#29869: the client stays away) or the session ends. The documentation of ChannelSource said nothing about this case, so E-Home's MonitorSource polled ReactWindowRegistry every 60 s to find out whether its window was still registered.
Solution
No new API is needed: the lifetime of such a monitor is the sub-session of the window. In the React UI each window has a sub-session of its own, and subscribe runs on a request thread of the window, so TLContextManager.getSubSession() returns it. TLSubSessionContext.addUnboundListener(SubSessionListener) informs the source when the sub-session is removed - both when the window is torn down (ReactWindowRegistry.windowClosed) and when the session ends. Keying the monitor by the sub-session instead of the ViewContext also lets the view instances rebuilt in the same window (after a login in the window, a reload of the view) find the running monitor again.
The JavaDoc of ChannelSource and the article view-layer/channels describe this pattern: the subscription is the time the view is displayed, not the lifetime of what runs behind it; whatever must keep running while the view is hidden is bound to the window's sub-session and ends with its unbound notification.
Adjustment in E-Home
MonitorSource registers a SubSessionListener on the sub-session of the subscribing window and stops the monitor when it is notified, instead of polling ReactWindowRegistry.