core icon indicating copy to clipboard operation
core copied to clipboard

fix(pipe): isObservable usage

Open iamnaumovnikita opened this issue 2 years ago • 2 comments

isObservable(res) instead of isObservable(res.subscribe)

I changed the usage of isObservable function to the correct one. Previously, it checks the subscribe function itself while it should check the observable itself. I also add a test that describes in which case it could lead to problem.

Without my fix the test is red and the actual result is

"{"operator": [Function anonymous], "source": {"_subscribe": [Function anonymous]}}"

image

With my fix the test is green.

image

In my test I described the scenario of a race condition when there is a bit delay of loading new language translation (after switching) and the usage MissingHandler with observable takes place.

P.S.

In many cases the next tick will solve the problem and user will see the correct translation, but there is a chance to see the stringified observable "{"operator": [Function anonymous], "source": {"_subscribe": [Function anonymous]}}"

In my PR I also removed some redundat imports.

iamnaumovnikita avatar Feb 09 '23 10:02 iamnaumovnikita