Commit a667c64fe16f51a3c04e6f7feb547076899a028b
1 parent
518aa41899
Exists in
master
and in
1 other branch
timeout okey
Showing
1 changed file
with
17 additions
and
11 deletions
Show diff stats
src/app/components/pedidos-salientes/pedidos-salientes.component.ts
... | ... | @@ -9,31 +9,37 @@ import { ComandaService } from 'src/app/services/comanda.service'; |
9 | 9 | export class PedidosSalientesComponent implements OnInit { |
10 | 10 | |
11 | 11 | private pedidosRecientes = []; |
12 | - private ciclo; | |
12 | + private cicloTime; | |
13 | 13 | |
14 | 14 | constructor(private comandaService: ComandaService) { } |
15 | 15 | |
16 | 16 | ngOnInit() { |
17 | - this.buscar(); | |
18 | 17 | |
19 | - this.ciclo = setTimeout(() => { | |
20 | - this.buscar(); | |
21 | - }, 5000) | |
18 | + this.buscar(); | |
19 | + this.ciclo(); | |
22 | 20 | } |
23 | 21 | |
24 | 22 | ngOnDestroy() { |
25 | 23 | |
26 | - clearTimeout(this.ciclo); | |
24 | + clearTimeout(this.cicloTime); | |
27 | 25 | } |
28 | 26 | |
29 | - buscar() { | |
27 | + ciclo() { | |
28 | + | |
29 | + this.cicloTime = setTimeout(() => { | |
30 | 30 | |
31 | + this.buscar(); | |
32 | + this.ciclo(); | |
33 | + }, 5000) | |
34 | + } | |
35 | + | |
36 | + buscar() { | |
31 | 37 | this.comandaService |
32 | - .getPendientesEntrega() | |
33 | - .subscribe((pedidos: []) => { | |
38 | + .getPendientesEntrega() | |
39 | + .subscribe((pedidos: []) => { | |
34 | 40 | |
35 | - this.pedidosRecientes = pedidos; | |
36 | - }, console.log); | |
41 | + this.pedidosRecientes = pedidos; | |
42 | + }, console.log); | |
37 | 43 | } |
38 | 44 | |
39 | 45 | rellenar(relleno, longitud) { |