13 lines
517 B
TypeScript
13 lines
517 B
TypeScript
|
// SafariがBroadcastChannel未実装なのでライブラリを使う
|
||
|
import { BroadcastChannel } from 'broadcast-channel';
|
||
|
|
||
|
const ch = new BroadcastChannel<boolean | undefined>('reload');
|
||
|
|
||
|
// BroadcastChannelを用いて、クライアントが一斉にreloadするようにします。
|
||
|
export function unisonReload(forcedReload?: boolean) {
|
||
|
ch.postMessage(forcedReload);
|
||
|
location.reload(forcedReload as boolean);
|
||
|
}
|
||
|
|
||
|
ch.addEventListener('message', forcedReload => location.reload(forcedReload as boolean));
|