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(){ | |
| final obs = Observable<String>(); | |
| final items = List.generate(500,(i) => Observer<String>(obs)); | |
| obs.setState("ib"); | |
| } | |
| int fibonacci(int n) { | |
| if (n == 0 || n == 1) return n; | |
| return fibonacci(n - 1) + fibonacci(n - 2); |
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(){ | |
| final obs = Observable<String>(); | |
| final items = List.generate(500,(i) => Observer<String>(obs)); | |
| obs.setState("ib"); | |
| } | |
| int fibonacci(int n) { | |
| if (n == 0 || n == 1) return n; | |
| return fibonacci(n - 1) + fibonacci(n - 2); |
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
| abstract class ITodoDao{ | |
| Future<List<Todo>> findAll(); | |
| Future<Todo> findById(int id); | |
| Future<void> delete(int id); | |
| } |
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
| class ShoppingCartNotifier extends ChangeNotifier { | |
| ShoppingCart cart = ShoppingCart(); | |
| remove(Item item) { | |
| cart.remove(item); | |
| notifyListeners(); | |
| } | |
| add(Item item) { |
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
| class CartBloc extends BlocBase { | |
| Observable<double> total; | |
| Observable<List<CartItem>> itens; | |
| Observable<ShoppingCart> _cartBase; | |
| set add(Product i) => _add.sink.add(i); | |
| set delete(CartItem i) => _remove.sink.add(i); | |
| final _add = BehaviorSubject<Product>(); | |
| final _cart = BehaviorSubject<ShoppingCart>.seeded(ShoppingCart()); |
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
| class SearchNotifier extends ChangeNotifier { | |
| final GithubApi _api; | |
| Timer _timer; | |
| CancelableOperation<SearchResult> _operation; | |
| SearchResult _result; | |
| SearchResult get result => _result; | |
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
| class SearchBloc { | |
| Observable<SearchResult> result; | |
| final _query = PublishSubject<String>(); | |
| Sink<String> get addQuery => _query.sink; | |
| SearchBloc() { | |
| final _api = GithubApi(); | |
| result = _query | |
| // Accepting only differents querys | |
| .distinct() |
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)); | |
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>(); | |
| Observable newStream = behavior | |
| .asyncMap((value) => /* alguma computacao assíncrona....*/); | |
| // ouve o novo Observable criado | |
| newStream.listen(print); | |
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>(); | |
| // transformando cada letra que o Observable emitir em sua versão maiúscula, usando a função toUpperCase(), transformamos | |
| // uma String, em sua representação em letra maíscula | |
| Observable newStream = behavior | |
| .map((c) => c.toUpperCase()); |
NewerOlder