Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dart: convert Observable to Future and vice-versa?

Tags:

dart

rxdart

How can I convert a Dart Observable to a Future and vice-versa?

like image 501
Daniel Oliveira Avatar asked Nov 20 '18 13:11

Daniel Oliveira


1 Answers

To convert a Observable to a Future:

  • myObservable.first
  • myObservable.firstWhere

To convert a Future to an Observable:

  • Observable.fromFuture(myFuture)

Or into a simple stream:

  • myFuture.asStream()
like image 163
Daniel Oliveira Avatar answered Oct 14 '22 13:10

Daniel Oliveira