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