The phrasing of the rxjs 5-6 migration instructions, as well as blog posts like this one imply that simply by having 'rxjs-compat' as a dependency of our project alongside 'rxjs' then Observables, Subjects, etc imported from 'rxjs' will be compatible with legacy operators. eg. Observable.of(3, 4, 5).concatMap(num => {/*...*/})
. However, this does not seem to be the case for us. Things do work somewhat as expected if we import directly from 'rxjs-compat' which doesn't seem to be the intended migration path and is also inconvenient in that the TypeScript declarations for 'rxjs' are more complete, and having imports for both 'rxjs' and 'rxjs-compat' in the same file will be mildly annoying to clean up in the future. Is there an additional step, or is importing from 'rxjs-compat' to be expected?
Asked
Active
Viewed 161 times
1

anomico
- 11
- 2
1 Answers
0
Just refactor your code and don't use the compatibility layer.
Observable.of(3, 4, 5).concatMap(num => {/*...*/})
becomes
of(3, 4, 5).pipe(concatMap(num => {/*...*/}))
You will be much better off doing the refactor up front.

Adrian Brand
- 20,384
- 4
- 39
- 60
-
Unfortunately, the codebase is rather large and the appeal of rxjs-compat is that it would enable progressive migration rather than requiring us to change everything at once. – anomico Mar 07 '19 at 20:00
-
I thought the same thing when we upgraded from Angular 5 to 6. I was going to use the compat layer but my dev lead told me not to. I am glad we did it that way now. The compiler told me where all the things that needed to be fixed were and it was done in half a day. I think the effort was well worth it. – Adrian Brand Mar 07 '19 at 23:42