Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

$interval does not get flushed #11912

@vytautas-pranskunas-

Description

@vytautas-pranskunas-

Hello,

because of protractor some issues i switched from $timeout to $interval but there i have an issue - $interval does not get flushed.

I modified plunker code which was originally created for other purposes but there i cannot get interval flushed too. Can you look at it please?

Just go to: http://plnkr.co/edit/tBth2b?p=preview
to module.js and replace

module.controller('ViewCtrl',
[         '$scope','$routeParams','TestService',
  function($scope,  $routeParams,  TestService) {

    $scope.increaseValue = function(){
      TestService.increaseValue();
    };

  }
]);

to

module.controller('ViewCtrl',
[         '$scope','$routeParams','TestService', '$interval',
  function($scope,  $routeParams,  TestService, $interval) {

    $scope.increaseValue = function(){

       var int = $interval(function(){
            console.log("interval flushed");
            TestService.increaseValue();
            $interval.cancel(int);
        }, 5000);

      $interval.flush(0);


    };

  }
]);

press on button 'Increase shared value' and see that value gets increased after 5 seconds but not immediately. This is basically issue in my ui tests.

any ideas?

Thanks

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions