Skip to content
Snippets Groups Projects
Commit 94f7648b authored by François's avatar François
Browse files

HttpService.httpGetRequest() : modif pour exécuter correctement la fonction de...

HttpService.httpGetRequest() : modif pour exécuter correctement la fonction de traitement (processDataCallback) dans la chaîne des Promise
- InternationalisationService.setLocale() : modif pour ne pas recharger inutilement les données d'internationalisation
parent 61b0da84
No related branches found
No related tags found
No related merge requests found
...@@ -27,17 +27,16 @@ export class HttpService { ...@@ -27,17 +27,16 @@ export class HttpService {
public httpGetRequest(protocol: string, host: string, port: number, path: string, public httpGetRequest(protocol: string, host: string, port: number, path: string,
processDataCallback: (s: string) => void, processDataCallback: (s: string) => void,
errorCallback?: (err: any) => void, errorCallback?: (err: any) => void,
headers?: StringMap): Promise<Response> { headers?: StringMap): Promise<any> {
let resp: Observable<Response> = this.httpGetRequestResponse(protocol, host, port, path, headers);
resp.map(res => res.text()) const prom = this.httpGetRequest2(protocol, host, port, path);
.subscribe( prom.then(data => {
data => processDataCallback(data), processDataCallback(data);
err => { if (errorCallback) errorCallback(err) }, }).catch(err => {
// () => console.log('Random Quote Complete') if (errorCallback)
); errorCallback(err)
});
return resp.toPromise(); return prom;
} }
/** /**
......
...@@ -99,10 +99,15 @@ export class InternationalisationService extends Observable { ...@@ -99,10 +99,15 @@ export class InternationalisationService extends Observable {
this._currLang = this.getLanguageFromCode(lng); this._currLang = this.getLanguageFromCode(lng);
} }
let prom = this.httpGetMessages(); if (this._currLang.code !== oldLang) {
prom.then((res) => { this._Messages = undefined;
this.notifyObservers(undefined); const prom = this.httpGetMessages();
})
const is: InternationalisationService = this;
prom.then((res) => {
is.notifyObservers(undefined);
})
}
} }
private httpGetMessages(): Promise<Response> { private httpGetMessages(): Promise<Response> {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment