title: Can not return from a function
body: <p>I have a function that looks like following </p>
  
  <pre><code>export const checkForAvailableAgent = (topicId, serviceUrl, serviceId) =&gt; {
    const serviceInfo = new window.adiaLive.ServiceInfo({
      topicId: topicId, // set here the topicId which you want listen for
      OnError: e =&gt; {
        // react to error message (optional)
        console.log("error: ", e);
      },
      OnServiceStateChange: e =&gt; {
        if (e.ConnectedAdvisers &gt; 0) {
          // there are advisers online for given topicId
          console.log("studio available");
          return true;
        } else {
          console.log("studio not available");
          return false;
        }
      }
    });
    serviceInfo.connect(serviceUrl, serviceId);
  };
  </code></pre>
  
  <p>however the return statements don't return anything when I use the function in the following manner</p>
  
  <pre><code>useEffect(() =&gt; {
      const agent = checkForAvailableAgent(
        `sales_${i18n.language}`,
        "https://linktoserviceurl",
        "serviceid"
      );
  
      // console.log("studio available is: ", agent);
    }, []);
  </code></pre>
  
  <p>the console.log massages appear but the return statement is undefined.</p>
  
  <p>any help would be appreciated.</p>