peerStore loading order caused issues. Fixed in GameScene (+ extracted a few stores in their files)
This commit is contained in:
parent
6ed8ce9af1
commit
2f282e3469
6 changed files with 57 additions and 55 deletions
16
front/src/Stores/VisibilityStore.ts
Normal file
16
front/src/Stores/VisibilityStore.ts
Normal file
|
@ -0,0 +1,16 @@
|
|||
import {readable} from "svelte/store";
|
||||
|
||||
/**
|
||||
* A store containing whether the current page is visible or not.
|
||||
*/
|
||||
export const visibilityStore = readable(document.visibilityState === 'visible', function start(set) {
|
||||
const onVisibilityChange = () => {
|
||||
set(document.visibilityState === 'visible');
|
||||
};
|
||||
|
||||
document.addEventListener('visibilitychange', onVisibilityChange);
|
||||
|
||||
return function stop() {
|
||||
document.removeEventListener('visibilitychange', onVisibilityChange);
|
||||
};
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue