-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RxJS incorrectly defines observable symbol #4415
Comments
Need some digging, esp why our interop utility doesn't work based on import order. couple of clarifications meanwhile
I think we already do, need to figure out why it doesn't work.
from v6, we intentionally removed polyfilling symbol for our own but only check if symbol exists. |
If RxJS loads and there is no If |
Don't we revalidate existense of symbol each time time when fn called? I thought we did that. |
Uh welp. 😅 |
Any updates on this? I faced this issue with refract-rxjs which revalidates existence of symbol. It brought a hard to track bug that started to occur when I reordered my imports. |
I'm experiencing this too, unable to convert |
Digging into this: It looks like the issue is we're not using In the end, I'm not sure what we should do here to fix the typings though. It seems like once something is imported from another module or otherwise stuffed in a variable, TypeScript gets rather confused about what works and what doesn't. |
There is another issue in the original post here, which is that, really, polyfills should always be applied before any libraries are loaded. So the runtime fix would be to just ensure the polyfilling happened first before the other imports. The TypeScript issue I'm not sure we can fix at the moment. I'm closing this for now, but I'm willing to reopen this later if this becomes a major issue. This is related to issue #3890, and there's a solid workaround for the typings issue The runtime issue can be resolved with a simple polyfill or just changing the order of imports. // Running this code before any of your imports will resolve any runtime issues.
if (typeof Symbol === 'function') {
if (!Symbol.observable) {
Symbol.observable = Symbol('observable');
}
} |
Bug Report
It would appear that the current way RxJS detects other observables is not working as expected, while other libraries can adapt from each other.
Current Behavior
The
from
function in RxJS 6.3.3 does not seem able to adaptxstream
andmost
while the older RxJS 5Observable.from
was able to. The following error is reproduced in both cases:Both
xstream
andmost
provideSymbol
polyfills:Additional testing has confirmed:
webpack
but it does innode
,jest
, andbrowserify
.Reproduction
xstream
torxjs
, does not work:xstream
torxjs
, working after importingxstream
first:most
, not working:rxjs
toxstream
either unless we importxstream
first:Expected behavior
The order of import should not matter, and the
jest
environment would work likewebpack
.Environment
Possible Solution
rxjs/src/internal/symbol/observable.ts
could be defined the same way the other libraries do it:isInteropObservable
could be patched to check for the same symbolxstream
andmost
use?xstream
ormost
could be included?Additional context/Screenshots
cyclejs
project withrxjs
.jest.setup.js
seems to have fixed the issue for now:Thank you and sorry in advance if I've diagnosed the wrong source 🙇♂️
The text was updated successfully, but these errors were encountered: