()
| 13 | #setup: SetupFn |
| 14 | |
| 15 | constructor() { |
| 16 | super() |
| 17 | this.#setup = (onFocus) => { |
| 18 | // addEventListener does not exist in React Native, but window does |
| 19 | // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition |
| 20 | if (typeof window !== 'undefined' && window.addEventListener) { |
| 21 | const listener = () => onFocus() |
| 22 | // Listen to visibilitychange |
| 23 | window.addEventListener('visibilitychange', listener, false) |
| 24 | |
| 25 | return () => { |
| 26 | // Be sure to unsubscribe if a new handler is set |
| 27 | window.removeEventListener('visibilitychange', listener) |
| 28 | } |
| 29 | } |
| 30 | return |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | protected onSubscribe(): void { |
| 35 | if (!this.#cleanup) { |
nothing calls this directly
no outgoing calls
no test coverage detected