Please upgrade to 100% RxJS v5 ASAP
This library is meant as a stop gap to help ease migration progressively, not as a band-aid for indefinite interop.
This has a peer dependencies of
rx@4.*.*, which will have to be installed as well.
npm install --save rxjs-compatibility
Note: this library does not provide automatic interop between the two for cases like
v4.flatMap(() => v5), etc. You must explicitly "convert" between the two.
When you convert from one Observable version to the other, keep in mind that if it's currently in v4 "mode", you'll only have v4 operators until you convert it back to v5 and vice versa. Effectively the result of one is piped into the other, just like how normal operators work.
The most ergonomic way to convert between the two versions is via the included operators patched on both Observable prototypes.
At some entry point file, you first run this to patch them:
If you need to customize what Observable prototypes get patched, you can optionally provide them as v4 and v5 arguments:
This is usually only neccesary when you're not using CommonJS modules. e.g. UMD builds of v4 and v5 use the same global variable
window.Rx so you need to store them elsewhere and then provide them to the
Converts the current Observable to a v4 Observable. Exists and works on both v5 Observables and ones that are already v4 too, in which case they just return
RxV5Observable;// 2, 3, 4
Converts the current Observable to a v5 Observable. Exists and works on both v4 Observables and ones that are already v5 too, in which case they just return
RxV4Observable;// 2, 3, 4
You can give it a spin in JSBin: http://jsbin.com/foqara/edit?js,output
Notice that because JSBin doesn't support a module system and instead uses global variables, you have to provide the Observable classes you want to patch.
If you need to convert an existing observable and don't want to (or can't) patch the prototype, you can use the provided helpers:
;const v5 = ObservableV5;instanceof ObservableV4;// true