Notify other tabs/windows.
(message: Record<string, unknown>)
| 108 | }, |
| 109 | /** Notify other tabs/windows. */ |
| 110 | post(message: Record<string, unknown>) { |
| 111 | if (typeof window === 'undefined') return; |
| 112 | try { |
| 113 | localStorage.setItem( |
| 114 | name, |
| 115 | JSON.stringify({ ...message, timestamp: now() }) |
| 116 | ); |
| 117 | } catch { |
| 118 | /** |
| 119 | * The localStorage API isn't always available. |
| 120 | * It won't work in private mode prior to Safari 11 for example. |
| 121 | * Notifications are simply dropped if an error is encountered. |
| 122 | */ |
| 123 | } |
| 124 | }, |
| 125 | }; |
| 126 | } |
| 127 |