forked from angular/protractor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathasync.js
70 lines (61 loc) · 2 KB
/
async.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
function AsyncCtrl($scope, $http, $timeout, $location) {
$scope.slowHttpStatus = 'not started';
$scope.slowFunctionStatus = 'not started';
$scope.slowTimeoutStatus = 'not started';
$scope.slowAngularTimeoutStatus = 'not started';
$scope.slowAngularTimeoutPromiseStatus = 'not started';
$scope.slowHttpPromiseStatus = 'not started';
$scope.routingChangeStatus = 'not started';
$scope.templateUrl = "/fastTemplateUrl";
$scope.slowHttp = function() {
$scope.slowHttpStatus = 'pending...';
$http({method: 'GET', url: '/slowcall'}).success(function() {
$scope.slowHttpStatus = 'done';
})
};
$scope.slowFunction = function() {
$scope.slowFunctionStatus = 'pending...';
for (var i = 0, t = 0; i < 500000000; ++i) {
t++;
}
$scope.slowFunctionStatus = 'done';
}
$scope.slowTimeout = function() {
$scope.slowTimeoutStatus = 'pending...';
window.setTimeout(function() {
$scope.$apply(function() {
$scope.slowTimeoutStatus = 'done';
});
}, 5000);
};
$scope.slowAngularTimeout = function() {
$scope.slowAngularTimeoutStatus = 'pending...';
$timeout(function() {
$scope.slowAngularTimeoutStatus = 'done';
}, 5000);
};
$scope.slowAngularTimeoutPromise = function() {
$scope.slowAngularTimeoutPromiseStatus = 'pending...';
$timeout(function() {
// intentionally empty
}, 5000).then(function() {
$scope.slowAngularTimeoutPromiseStatus = 'done';
});
};
$scope.slowHttpPromise = function() {
$scope.slowHttpPromiseStatus = 'pending...';
$http({method: 'GET', url: '/slowcall'}).success(function() {
// intentionally empty
}).then(function() {
$scope.slowHttpPromiseStatus = 'done';
});
};
$scope.routingChange = function() {
$scope.routingChangeStatus = 'pending...';
$location.url('/slowloader');
};
$scope.changeTemplateUrl = function() {
$scope.templateUrl = "/slowTemplateUrl";
};
};
AsyncCtrl.$inject = ['$scope', '$http', '$timeout', '$location'];