Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why do we need to wrap a provider for FirebaseAuth.instance? #92

Closed
amoslai5128 opened this issue Jul 26, 2022 · 2 comments
Closed

Why do we need to wrap a provider for FirebaseAuth.instance? #92

amoslai5128 opened this issue Jul 26, 2022 · 2 comments

Comments

@amoslai5128
Copy link

amoslai5128 commented Jul 26, 2022

Hi, I'm a starter of Riverpod and feel confused about the wrapping provider for instance. Therefore, I want to know why:

In your example:

// 1
final firebaseAuthProvider =
    Provider<FirebaseAuth>((ref) => FirebaseAuth.instance);

// 2
final authStateChangesProvider = StreamProvider<User>(
    (ref) => ref.watch(firebaseAuthProvider).authStateChanges());

What if?

// Directly use its singleton?
final authStateChangesProvider = StreamProvider<User>(
    (ref) => FirebaseAuth.instance.authStateChanges());
@demirdev
Copy link

demirdev commented Aug 2, 2022

The purpose here is accessing FirebaseAuth with riverpod for easy testing. Otherwise how can we Mock FirebaseAuth ?

@bizz84
Copy link
Owner

bizz84 commented Jan 7, 2023

Closing following changes in #94.

Feel free to open new issues if needed.

@bizz84 bizz84 closed this as completed Jan 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants