It’s a nice solution! However, while testing it by triggering an event that causes a flash notification multiple times within the preconfigured 5 seconds, I consistently encountered the following error:
view.js:1521 Uncaught (in promise) Error: unable to push hook event. LiveView not connected
at _View.pushHookEvent (view.js:1521:9)
at _ViewHook.pushEvent (view_hook.ts:388:35)
at hooks.js:19:12
pushHookEvent @ view.js:1521
pushEvent @ view_hook.ts:388
(anonymous) @ hooks.js:19
setTimeout
mounted @ hooks.js:17
So, I slightly modified it, probably not perfectly, by wrapping this.pushEvent in the following if clause: