Commit 7ba58952 authored by dev0tion's avatar dev0tion

Add startWith to polling

parent 88671d48
......@@ -5,6 +5,7 @@ import 'rxjs/add/operator/map';
import 'rxjs/add/operator/switchMap';
import 'rxjs/add/operator/catch';
import "rxjs/add/observable/interval";
import 'rxjs/add/operator/startWith';
import { WalletCreation } from '../classes/wallet-creation';
import { WalletRecovery } from '../classes/wallet-recovery';
......@@ -24,7 +25,7 @@ export class ApiService {
private mockApiUrl = 'http://localhost:3000/api';
private webApiUrl = 'http://localhost:5000/api';
private headers = new Headers({'Content-Type': 'application/json'});
private pollingInterval = 2000;
private pollingInterval = 3000;
/**
* Gets available wallets at the default path
......@@ -80,6 +81,7 @@ export class ApiService {
return Observable
.interval(this.pollingInterval)
.startWith(0)
.switchMap(() => this.http.get(this.webApiUrl + '/wallet/balance', new RequestOptions({headers: this.headers, search: params})))
.map((response: Response) => response);
......@@ -97,6 +99,7 @@ export class ApiService {
return Observable
.interval(this.pollingInterval)
.startWith(0)
.switchMap(() => this.http.get(this.webApiUrl + '/wallet/history', new RequestOptions({headers: this.headers, search: params})))
.map((response: Response) => response);
......
......@@ -48,7 +48,6 @@ export class DashboardComponent {
private getWalletBalance() {
let walletInfo = new WalletInfo(this.globalService.getWalletName(), this.globalService.getCoinType())
this.walletBalanceSubscription = this.apiService.getWalletBalance(walletInfo)
.first()
.subscribe(
response => {
if (response.status >= 200 && response.status < 400) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment