2021-02-17 12:36:56 +00:00
|
|
|
// SafariがBroadcastChannel未実装なのでライブラリを使う
|
|
|
|
import { BroadcastChannel } from 'broadcast-channel';
|
|
|
|
|
2021-11-04 15:09:13 +00:00
|
|
|
export const reloadChannel = new BroadcastChannel<string | null>('reload');
|
2021-02-17 12:36:56 +00:00
|
|
|
|
|
|
|
// BroadcastChannelを用いて、クライアントが一斉にreloadするようにします。
|
2021-11-04 15:09:13 +00:00
|
|
|
export function unisonReload(path?: string) {
|
|
|
|
if (path !== undefined) {
|
|
|
|
reloadChannel.postMessage(path);
|
|
|
|
location.href = path;
|
|
|
|
} else {
|
|
|
|
reloadChannel.postMessage(null);
|
|
|
|
location.reload();
|
|
|
|
}
|
2021-02-17 12:36:56 +00:00
|
|
|
}
|