Last active
August 20, 2019 09:49
-
-
Save rullyalves/a9639646dad075f16657f23b8a450590 to your computer and use it in GitHub Desktop.
RXDart operador asyncMap com chamada de API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void main() async { | |
| final behavior = new BehaviorSubject<String>(); | |
| // pegando cada valor adicionado ao Observable, fazendo uma requisição em uma Api externa e retornando uma lista de resultados | |
| // assim transformando um simples texto em uma lista de resultados vindos da Api | |
| Observable<List> newStream = behavior | |
| .asyncMap((value) => Api.searchProducts(value)); | |
| // ouve o novo Observable criado | |
| newStream.listen(print); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment