Skip to content

Instantly share code, notes, and snippets.

@jacobaraujo7
Last active May 18, 2021 14:22
Show Gist options
  • Save jacobaraujo7/2d41d0ac18f9051a779135f7f7e68238 to your computer and use it in GitHub Desktop.
Save jacobaraujo7/2d41d0ac18f9051a779135f7f7e68238 to your computer and use it in GitHub Desktop.
//avaliable in Dart 2.13
typedef ProductList = List<Product>;
class ProductStore extends StreamStore<Exception, ProductList> {
final ProductRepository repository;
Counter({required this.repository}): super([]);
fetchProduct() async {
setLoading(true);
try {
final list = await repository.fetchAllProducts();
update(list);
} on Exception catch (e) {
setError(e);
} finally {
setLoading(false);
}
}
}
@celsogithub
Copy link

Dear @jacobaraujo7, the constructor name in the line 8 is incorrect (it should be ProductStore), right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment