That is indeed a nice solution. But if we are building a UI node, it would be nice IMHO to have this functionality in the node. Because that keeps our flows simple. I mean a checkbox "don't push data if widget not visible". Then you can keep sending messages (containing m4 fragments) to the UI node, but they won't be pushed to the dashboard when the widget is not visible at the moment.
Although I'm not sure (I'm not at my computer) whether it is possible currently - in the server side beforeEmit
function - to stop a message from being send to the client. See the feedback from @dceejayin this discussion, where is advised to send a message containing e.g. null in those cases. But perhaps that is possible meanwhile...
Anyway perhaps I'm going too much of topic now. If my proposal makes sense (and need further discussion), we better split this into a separate topic...