rename: client -> frontend
This commit is contained in:
15
packages/frontend/src/scripts/unison-reload.ts
Normal file
15
packages/frontend/src/scripts/unison-reload.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
// SafariがBroadcastChannel未実装なのでライブラリを使う
|
||||
import { BroadcastChannel } from 'broadcast-channel';
|
||||
|
||||
export const reloadChannel = new BroadcastChannel<string | null>('reload');
|
||||
|
||||
// BroadcastChannelを用いて、クライアントが一斉にreloadするようにします。
|
||||
export function unisonReload(path?: string) {
|
||||
if (path !== undefined) {
|
||||
reloadChannel.postMessage(path);
|
||||
location.href = path;
|
||||
} else {
|
||||
reloadChannel.postMessage(null);
|
||||
location.reload();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user