Observable is deprecated in rxdart 0.23.1

Pritish picture Pritish · Dec 14, 2019 · Viewed 16.8k times · Source

I just upgraded to rxdart 0.23.1 and suddenly I am getting errors wherever I have used the Observable class. I have read about the breaking changes in the documentation and it has specified to use the rxdart_codemod package which I have integrated in my pubspec.yaml file and running the following command pub global activate rxdart_codemod throws the -bash: pub: command not found error. I have installed flutter properly and flutter doctor also seems to be running fine. Is there some other class that have replace Observable, couldn't find anything about it in the docs. Of course I can replace the Observable with the Stream from Dart language but really interested to know what path does the rxdart package takes as it specifies it is taking advantage of the dart extension.Using methods like combineLatest2 is not possible with Dart's Stream so it won't be a good choice for replacement?

Answer

Pritish picture Pritish · Dec 15, 2019

The Observable can be replaced by Stream as I mentioned in the question but if you are using methods like combineLatest2 from Observable, then just replace Observable by abstract class Rx so you can use Rx.combineLatest2