Part of ENG-10186
The previous version had a bug:
const waitForConnection = useWaitForConnection('tunnelbroker');
const callback = React.useCallback(async () => {
// starting, TB is not connected
// doing some async staff here
// TB connects
await waitForConnection();
// above line throws timeout instead of being resolved because `useEffect` is not reactive to adding promise to the array,
// `isConnectedOrUnreachable` changed in the past, but in this example we calling outdated version of `waitForConnection`
// this diff fixes it
}, [
someOtherDependencies,
waitForConnection,
]);Depends on D14385