2022-04-27 12:57:59 -05:00
|
|
|
import { BroadcastChannel } from 'broadcast-channel';
|
|
|
|
|
|
|
|
export const reloadChannel = new BroadcastChannel<string | null>('reload');
|
2021-02-17 06:36:56 -06:00
|
|
|
|
|
|
|
// BroadcastChannelを用いて、クライアントが一斉にreloadするようにします。
|
2021-11-04 10:09:13 -05:00
|
|
|
export function unisonReload(path?: string) {
|
|
|
|
if (path !== undefined) {
|
|
|
|
reloadChannel.postMessage(path);
|
|
|
|
location.href = path;
|
|
|
|
} else {
|
|
|
|
reloadChannel.postMessage(null);
|
|
|
|
location.reload();
|
|
|
|
}
|
2021-02-17 06:36:56 -06:00
|
|
|
}
|