Skip to content

Instantly share code, notes, and snippets.

@rullyalves
Last active August 20, 2019 09:49
Show Gist options
  • Select an option

  • Save rullyalves/a9639646dad075f16657f23b8a450590 to your computer and use it in GitHub Desktop.

Select an option

Save rullyalves/a9639646dad075f16657f23b8a450590 to your computer and use it in GitHub Desktop.
RXDart operador asyncMap com chamada de API
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