@neovici/cosmoz-utils 6.15.1 → 6.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -12,7 +12,7 @@ declare class ConsumeDirective<T> extends AsyncDirective {
|
|
|
12
12
|
subscribe(emitter: Node): void;
|
|
13
13
|
render(context: Context<T>, pluck: (value: T) => unknown): unknown;
|
|
14
14
|
updater(value: T): void;
|
|
15
|
-
|
|
15
|
+
disconnected(): void;
|
|
16
16
|
}
|
|
17
17
|
interface Consume {
|
|
18
18
|
<T>(consume: Context<T>, pluck: (value: T) => unknown): DirectiveResult<typeof ConsumeDirective<T>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useDocumentVisibility: () => boolean;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useEffect, useState } from '@pionjs/pion';
|
|
2
|
+
export const useDocumentVisibility = () => {
|
|
3
|
+
const [visibility, setVisibility] = useState(document.visibilityState);
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
const handleVisibilityChange = () => {
|
|
6
|
+
setVisibility(document.visibilityState);
|
|
7
|
+
};
|
|
8
|
+
document.addEventListener('visibilitychange', handleVisibilityChange);
|
|
9
|
+
return () => {
|
|
10
|
+
document.removeEventListener('visibilitychange', handleVisibilityChange);
|
|
11
|
+
};
|
|
12
|
+
}, []);
|
|
13
|
+
return visibility === 'visible';
|
|
14
|
+
};
|