ngx-translate / core

The internationalization (i18n) library for Angular
MIT License
4.51k stars 574 forks source link

Observerable from TranslateService called only once #475

Closed stswoon closed 7 years ago

stswoon commented 7 years ago

I'm submitting a bug

[x] bug report => check the FAQ and search github for a similar issue or PR before submitting
[ ] support request => check the FAQ and search github for a similar issue before submitting
[ ] feature request

Current behavior Function as parameter inside subscribe (translateService.get().subscribe()) called only once. In case of using translateService.get().subscribe() after change language function in subscribe never calls again

Expected/desired behavior Observerable from translateService.get(key) should be endless to be able to call subscribe after any changes which can affect return value for key.

Reproduction of the problem

  1. open plunker
  2. click Toogle lang button

AR1=ER1: text after "Pipe" changed AR2: text after "Service" not changed ER2: text after "Service" changed (AR - actual result \ current behavoir; ER - expected result \expected behavoir)

What is the motivation / use case for changing the behavior? Use case to make work translateService.get().subscribe() same as pipe or directive.

Please tell us about your environment:

hpawe01 commented 7 years ago

Hello, I also ran into this problem: see the plunker based on the plunker of @ocombe with the current ngx-translate package (@stswoon: Your plunker uses the older ng2-translate package, that's why I created another one).

Does anyone can validate, that this is a bug? Or is it a missing feature? Or do we use it the wrong way?

stswoon commented 7 years ago

Ngx-translate team please respond at least bug it or not.

By the way I've tried to make fix, e.g. make subcription from get be called on every lang change (see link), it works but some test are failed now.

ocombe commented 7 years ago

It's not a bug, but it's a missing feature yes

yassernasc commented 6 years ago

any update about this missing feature?

CodeAndWeb commented 6 years ago

Use .stream() instead of .get()