Skip to content
This repository has been archived by the owner on Jul 26, 2023. It is now read-only.
/ angular-wait-until Public archive

Wait until an executed promise resolved to a true value

Notifications You must be signed in to change notification settings

AlonMiz/angular-wait-until

Repository files navigation

Build Status

Angular Wait Until

Wait until the executed promise resolved to a true value, Execute it every x milliseconds and stop after y milliseconds.

Install

npm install angular-wait-until

Usage

Angular Module

    angular.module('webApp', ['angular.wait-until'])

Inside a controller/service

    angular.module('webApp')
      .controller('myController', function ($scope, $q, WaitUntil) {
        var myPromise = new WaitUntil();
        var later = +Date.now() + 500;
        $scope.error = 'no error';
        
        myPromise
          .stopAfter(1 * 1000)
          .tryEvery(100)
          .stopOnFailure(false) //Ignore errors
          .execute(() => {
            return $q((resolve, reject) => {
              if (+Date.now() >= later) {
                return resolve(true); //some truthy value
              }
              reject(false);
            })
          })
          .then((value) => $scope.name = 'Yey')
          .catch((err) => $scope.error = err);
      });

Additional Features

This repo is based on poll-until-promise. There you can read about additional features and functionality

About

Wait until an executed promise resolved to a true value

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published