src/js/app.js
// waitForReadyState waits for ob-relay to report the READY status
waitForReadyState waits for ob-relay to report the READY status
waitForReadyState waits for ob - relay to report the READY status
function waitForReadyState(droplet) {
  let deferred = $.Deferred(),
    attempts = 0,
    statusAddr = 'https://deploy.ob1.io/cors/status/' + droplet.ipv4;
  function poll() {
    $.get(statusAddr)
    .always(function (data, requestStatus) {
      if (requestStatus === 'success') {
        droplet.state = NodeStates.enumValueOf(JSON.parse(data).status);
        if (droplet.state === NodeStates.READY) return deferred.resolve(droplet);
      }
      if (attempts >= getReadyStatusMaxAttempts) return deferred.reject(new Error('Too many attempts'));
      attempts++;
      setTimeout(poll, getReadyStatusPollInterval);
    });
  }
  poll();
  return deferred.promise();
}
function waitForReadyState ( droplet ) { let deferred = $ . Deferred ( ) , attempts = 0 , statusAddr = 'https://deploy.ob1.io/cors/status/' + droplet . ipv4 ; function poll ( ) { $ . get ( statusAddr ) . always ( function ( data , requestStatus ) { if ( requestStatus === 'success' ) { droplet . state = NodeStates . enumValueOf ( JSON . parse ( data ) . status ) ; if ( droplet . state === NodeStates . READY ) return deferred . resolve ( droplet ) ; } if ( attempts >= getReadyStatusMaxAttempts ) return deferred . reject ( new Error ( 'Too many attempts' ) ) ; attempts ++ ; setTimeout ( poll , getReadyStatusPollInterval ) ; } ) ; } poll ( ) ; return deferred . promise ( ) ; }
waitForReadyState waits for ob-relay to report the READY status
waitForReadyState waits for ob - relay to report the READY status
// If the request was successful see if we're in the READY status. If so we // are done. If not try again unless we're at our limit. // Update the droplet state if the request was successful. If it's READY // we're done so resolve the promise with the droplet. // Ensure we haven't tried too many times // Try again later // Start polling // Return a promise to try really hard or fail