Current behavior
TranslateService has the method get which returns an Observable of the translation.
If you want to use this in a async function, you need to wrap it into firstValueFrom. e.g.
await firstValueFrom(this.translateService.get("key"));
Expected behavior
There should be an async function that does the same as get but which returns a Promise instead of an Observable. e.g.
await this.translateService.getAsync("key");
What is the motivation / use case for changing the behavior?
I use a async a lot, so I need the firstValueFrom wrapper in a lot of places. If I create a custom function (see below) I would need to use _ every time to mark the translation.
How do you think that we should implement this?
public async getAsync(key: string | string[], interpolateParams?: InterpolationParameters): Promise<Translation> {
return firstValueFrom(this.get(key, interpolateParams));
}
Current behavior
TranslateService has the method
getwhich returns an Observable of the translation.If you want to use this in a async function, you need to wrap it into firstValueFrom. e.g.
Expected behavior
There should be an async function that does the same as
getbut which returns a Promise instead of an Observable. e.g.What is the motivation / use case for changing the behavior?
I use a async a lot, so I need the
firstValueFromwrapper in a lot of places. If I create a custom function (see below) I would need to use_every time to mark the translation.How do you think that we should implement this?