-
-
Notifications
You must be signed in to change notification settings - Fork 36
fix: Use BehaviorSubject for _onAuthStateChangedController #116
Conversation
Isn't |
@Vinzent03
To me, the main purpose of |
I believe you can do that by calling |
@bdlukaa Currently, this is what is happening.
At event 1, any auth event emitted during |
To me, In a Flutter context, this stream would only be used to update the screen. If a |
@bdlukaa There are no way of obtaining the value of the stream that was emitted previously in the default
I do agree that this could be a problem, but
if this is what you think is the ideal behavior, then this PR would enable it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds ok to me
@dshukertjr Have you tested that it "caches" the latest error as well for new listeners? I don't know if it may only do that for data events. |
@Vinzent03 I do understand your concern. But at the same time, I feel like the behavior in this PR is the behavior that people expect when listening to auth states as a stream as I have received few feedbacks about it. At least I think Firebase does it this way if I'm not wrong (It's been a while since I have used Firebase auth, so I could be wrong 😂). |
Okay that's great. I just tested with Firebase and you are right they emit the latest event on listening. So LGTM! |
What kind of change does this PR introduce?
Currently, there are no ways to listen to the very first recovery event through
onAuthStateChanged
stream, becauseSupabase.initialize()
completes after after the recovery event is handled.This PR changes the
_onAuthStateChangedController
to BehaviorSubject so that the last event is preserved and can be listened to even after theSupabase.initialize()
is completed.Related supabase/supabase-flutter#331
Other context
The commit message got mixed up with my previous task, so please ignore it 😂