File tree Expand file tree Collapse file tree 1 file changed +7
-24
lines changed Expand file tree Collapse file tree 1 file changed +7
-24
lines changed Original file line number Diff line number Diff line change 2
2
3
3
# timeout-service - use ` $timeout ` instead of ` setTimeout `
4
4
5
-
6
-
7
5
Instead of the default setTimeout function, you should use the AngularJS wrapper service $timeout
8
6
*
9
7
10
-
11
8
** Rule based on Angular 1.x**
12
9
13
-
14
-
15
10
** Styleguide Reference**
16
11
17
12
* [ y181 by johnpapa - Angular $ Wrapper Services - $timeout and $interval] ( https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y181 )
18
13
19
-
20
14
## Examples
21
15
22
-
23
-
24
16
The following patterns are considered problems;
25
17
26
18
/*eslint angular/timeout-service: 2*/
27
-
28
- // invalid
19
+
20
+ // invalid
29
21
setTimeout(function() {
30
22
// ...
31
23
}, 1000) // error: You should use the $timeout service instead of the default window.setTimeout method
32
-
33
24
34
- // invalid
25
+ // invalid
35
26
window.setTimeout(function() {
36
27
// ...
37
28
}, 1000) // error: You should use the $timeout service instead of the default window.setTimeout method
38
29
39
-
40
30
// invalid
41
31
$window.setTimeout(function() {
42
32
// ...
43
- }, 1000) // error: You should use the $timeout service instead of the default window.setTimeout method
44
-
45
-
46
-
33
+ }, 1000) // error: You should use the $timeout service instead of the default window.setTimeout method
47
34
48
35
The following patterns are ** not** considered problems;
49
36
50
37
/*eslint angular/timeout-service: 2*/
51
-
52
- // valid
38
+
39
+ // valid
53
40
$timeout(function() {
54
41
// ...
55
- }, 1000)
56
-
57
-
58
-
59
-
42
+ }, 1000)
60
43
61
44
## Version
62
45
You can’t perform that action at this time.
0 commit comments