-
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
No way to tell user they are using wrong version of RxJS (i.e v4 vs v5) #2817
Comments
Would you describe your usecases bit more? I don't think it's possible, cause if you check instance of observable itself any kind of extended classes (i.e, imagine user creates custom extended class based on Observable, for example like actionsObservable in redux-observable) that'll fail too. And extending class is valid use case of Observable. |
@kwonoj I have a library for building chatbots which allows a user to compose steps it should perform. These steps can return a raw value, or a function for synchronous steps. Or a promise or a RX.Observable for Async. Currently I can't determine if its a Observable. As internally I use RX.JS to compose streams which execute these steps so in the case of a raw value I use Rx.Observable.of. I'm currently getting a MapObservable or a CatchObservable out of nowhere which I can't find in the library |
I found that my library needed a v5 Observable but a project was passing in a v4 object. I need either a way of identifying when this is the case or if there is a way of specifying npm to an anti-dependency i.e Please do not let this library be installed with RxJS v4 Is there a way of determining when RxJS v4 is installed ? I'm super annoyed that v5 was given a new package name, it's made this hell. |
Can't you use the |
@paulpdaniels The issue is a user was passing in an Observable from a previous version of the library. Of course in my package I declare v5 and above. |
Adding a property to indicate the version is trivial. Why hasn't this been added? |
Hi @jcampbell05! :) From my conversations with @cartant I would now explain it like that: The version is in package.json. At Runtime: So as far as I understand, the following psudo code should "work": const rxjs5Observable = ofRxJS5('rxjs5');
const rxjs6Observable = ofRxJS6('rxjs6');
const rxjs7Observable = ofRxJS7('rxj7');
fromRxJS6(rxjs5Observable);
fromRxJS7(rxjs6Observable);
fromRxJS7(fromRxJS6(rxjs5Observable)); I hope this is solving your problem in v5 and above. If there are other questions or I did not answer your question, please let me know. Best, |
In the end I simply detect if I can resolve the RX v4 package, IF I can then it's been installed so I can refuse to run until they uninstall it for the project. Not ideal would have preferred a way to just throw an error when I detect a RXv4 Observable. |
It would throw an error if you attempted to do |
Cool, that's a reasonable way of doing it I'll give that a go. Thanks! |
Closing this as resolved. |
RxJS version:
5.4.0
Code to reproduce:
Create an observable, do some stuff in typescript like map it or filter it and then use instanceof to determine if it's a Rx.Observable.
Expected behavior:
x instanceof Rx.Observable should return true
Actual behavior:
It returns false as the observables given are instances of AnomynousObservables or MapObservalbes and 5.0 removes isObservable as well.
Additional information:
The text was updated successfully, but these errors were encountered: