title: How to return a value from a function with subscribe?
body: <p>This is a function in Javascript that I need for checking an Angular service by subscribe if it contains an array or not but the the return value is undefined because the function doesn't change the variable value inside the subscribe. </p>
  
  <pre><code>    function checkAvailableBonus() {
          var dataSize = 0;
          var returnValue = "false";
          window.angularComponentRef.component.slotsBonusesService.getPlayerAvailableBonuses().subscribe(function (data) {
              dataSize = data.length;
              if (dataSize !== 0) {
                  returnValue = "true";
              } else {
                  returnValue = "false";
              }
  
          });
          return (returnValue);
      }
      checkAvailableBonus();
  </code></pre>
  
  <p>I except the function to return "true"/"false" after the subscribe was done.</p>