Closed logemann closed 4 years ago
For firebase you will want to use AutoDisposeStreamProvider, to stop the subscription ASAP when the UI doesn't use the value anymore
good hint. Wasnt aware of the class alltogether ;-)
I think it would be super nice to have little code example inside the API doc like with https://pub.dev/documentation/riverpod/latest/riverpod/StateNotifierProvider-class.html. Would speed up adoption drastically.
And to me its not clear how to handle the types when constructing the provider as well as with the caller of the hook useProvider(firebaseAuthProvider)
I strongly agree. I really love your libraries but it takes me some time to figure out how to use them optimally due to lack of examples. Even something simple would go a long way. That said, I plan to share some of the things I come up with.
I'm finishing #39 first, which will make documenting providers easier. Then I'll document all providers individually.
Tying together the above comments with the newly introduced syntax:
StreamProvider.autoDispose((ref) => FirebaseAuth.instance.onAuthStateChanged)
Thanks for the updates Remi!
@AlexHartford so AutoDisposeStreamProvider is already outdated and one should use StreamProvider.autoDispose() ?
The syntax changed a bit recently, yes. But AutoDisposeStreamProvider and StreamProvider.autoDispose are strictly equivalent.
thanks. Just noticed that i wasnt on latest version.
I would like to see a more detailed example with StreamProvider in the docs. I think in the flutter / firebase context, a really nice example would be the equivalent of this from the provider way of things:
translated to River Pod, it might look like this, but i could be wrong (since i am trying to clean up here, its not 1:1 translation as is):
Please correct me if i am wrong on this.