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 {
public httpGetRequest(protocol: string, host: string, port: number, path: string,
processDataCallback: (s: string) => void,
errorCallback?: (err: any) => void,
headers?: StringMap): Promise<Response> {
let resp: Observable<Response> = this.httpGetRequestResponse(protocol, host, port, path, headers);
headers?: StringMap): Promise<any> {
resp.map(res => res.text())
.subscribe(
data => processDataCallback(data),
err => { if (errorCallback) errorCallback(err) },
// () => console.log('Random Quote Complete')
);
return resp.toPromise();
const prom = this.httpGetRequest2(protocol, host, port, path);
prom.then(data => {
processDataCallback(data);
}).catch(err => {
if (errorCallback)
errorCallback(err)
});
return prom;
}
/**
......
......@@ -99,10 +99,15 @@ export class InternationalisationService extends Observable {
this._currLang = this.getLanguageFromCode(lng);
}
let prom = this.httpGetMessages();
prom.then((res) => {
this.notifyObservers(undefined);
})
if (this._currLang.code !== oldLang) {
this._Messages = undefined;
const prom = this.httpGetMessages();
const is: InternationalisationService = this;
prom.then((res) => {
is.notifyObservers(undefined);
})
}
}
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