-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Observe Single event method returning cached data #84
Comments
Thanks for sending over this issue. While I understand that this can be frustrating, this is expected behavior. Single even observers will return data from the cache if there is data available. This allows us to fire them immediately. If you use .value observers, you will receive updated data in its second call. |
I suppose this makes sense. But, is there a way to do have it pull from the server immediately/initially, without having to call it twice? Am I suppose to use the non-single event methods, then cancel the observer manually? Also, I would say the documentation should be updated. |
* Adds “reset password in app” to sample app * Addresses comments * Addresses comments
* Adds passing state and continue URL in OOBCodes actions. (#82) * Adds actionCodeSettings class (#83) * Adds FIRActionCodeSettings class * Removes iOSAppStoreId to reflect update spec. * Adds “reset password in app” to sample app (#84) * Adds “reset password in app” to sample app * Addresses comments * Addresses comments * Adds @param documentation for actionCodeSettings (#85) Adds @param documentation for actionCodeSettings in FIRGetOOBConfirmationCodeRequest. * Adds request configuration class Adds a class that will comprise of all configurations needed to make a request to the Firebase Auth backend; including APIKey and Language code in the future. * Addresses comments. * Adds Setting Language Add Setting Language Feature to Firebase Auth. - Only adds support for two languages (English and Spanish) in this change. (Also supports two languages in test), more to come after this change is accepted. - For now sample app tests language setting only when using “reset password in app” option, the email sent will be in the current app language. Additional tests to come after change is accepted. * Amends code for unit tests Will add more comprehensive testing when code accepted. * Ecodes strings files in UTF-8 * Addresses comments * Addresses comments * Remove comments in .strings * Adds remaining TC languages to Firebase Auth. * Add line break to .strings files * remove language code english fallback Remove the fallback that sends “en” as the language code to the backend if no language code is specified. * addresses comment * Fixes FIRSecureToken Crash Integrates FIRSecureTokenService and FIRSecureTokenRequest with FIRAuthRequestConfiguration. * Addresses comment * Add auth language input Adds Auth language input to the Sample App in preparation for manual testing. * removes unnecessary comment * address comments * Add app language option Allow user to set the current app language code as the auth language code. This is in preparation for manual testing before release. * Addresses Comment * Adds missing continue URI Adds missing continue URL to Firebear error handling. * Remove unused line Removes unused line from FIRPhoneAuthProvider.m * Moves the new public header to the right place. * Fixes broken macOS build. * Removes trailing spaces. * Addresses review comments.
Any update? |
@MarksCode What kind of update are you looking for? This issue was closed as "expected behavior". stackoverflow is a better place to ask usage questions. |
Is there a better way of doing this? I've noticed that when using a cache and attempting a |
@quanvo87 load time is going to depend on the size of the data you're loading and the quality of your internet connection. Are you observing one minute load times for small queries on good internet? |
@morganchen12 When testing this, I was querying an endpoint that returned a small String. My connection is 15 ping 50/10 down/up. I could probably be more clear--by 55-60 attempts, what I mean is I did a |
Oh, I misread your last comment. With the current API, observing a single event with persistence enabled doesn't let you specify whether you're trying to retrieve cached or server data. The SDK defaults to returning cached data, but this isn't useful if you're trying to retrieve server data. For the time being you should use value listeners instead like Sebastian mentioned above, but this does seem like a non-feature. |
* Adds passing state and continue URL in OOBCodes actions. (firebase#82) * Adds actionCodeSettings class (firebase#83) * Adds FIRActionCodeSettings class * Removes iOSAppStoreId to reflect update spec. * Adds “reset password in app” to sample app (firebase#84) * Adds “reset password in app” to sample app * Addresses comments * Addresses comments * Adds @param documentation for actionCodeSettings (firebase#85) Adds @param documentation for actionCodeSettings in FIRGetOOBConfirmationCodeRequest. * Adds request configuration class Adds a class that will comprise of all configurations needed to make a request to the Firebase Auth backend; including APIKey and Language code in the future. * Addresses comments. * Adds Setting Language Add Setting Language Feature to Firebase Auth. - Only adds support for two languages (English and Spanish) in this change. (Also supports two languages in test), more to come after this change is accepted. - For now sample app tests language setting only when using “reset password in app” option, the email sent will be in the current app language. Additional tests to come after change is accepted. * Amends code for unit tests Will add more comprehensive testing when code accepted. * Ecodes strings files in UTF-8 * Addresses comments * Addresses comments * Remove comments in .strings * Adds remaining TC languages to Firebase Auth. * Add line break to .strings files * remove language code english fallback Remove the fallback that sends “en” as the language code to the backend if no language code is specified. * addresses comment * Fixes FIRSecureToken Crash Integrates FIRSecureTokenService and FIRSecureTokenRequest with FIRAuthRequestConfiguration. * Addresses comment * Add auth language input Adds Auth language input to the Sample App in preparation for manual testing. * removes unnecessary comment * address comments * Add app language option Allow user to set the current app language code as the auth language code. This is in preparation for manual testing before release. * Addresses Comment * Adds missing continue URI Adds missing continue URL to Firebear error handling. * Remove unused line Removes unused line from FIRPhoneAuthProvider.m * Moves the new public header to the right place. * Fixes broken macOS build. * Removes trailing spaces. * Addresses review comments.
Why in the Second call? As we expect refreshed data whenever we apply the observer to the Database Reference. I tried below code too, its also not refreshing the data
|
[READ] Step 1: Are you in the right place?
Yes
[REQUIRED] Step 2: Describe your environment
[REQUIRED] Step 3: Describe the problem
We are facing the below issue on our iOS app that uses firebase iOS SDk.
To give you some context, the users of our app are part of Groups. Each of these groups have some group information.
In the database we have user who is mapped with a list of group IDs. Using these Group Ids Further we fetch group’s info. Below is the structure.
Whenever there is a change in group’s info, we have a firebase cloud fuction that updates the timestamp at both the places. Hence any change to group’s info would notify the observers at both references
database\GroupID1
anddatabase\User1
The issue we are facing is that we have a continuous observer at reference
database\User1
using the method observe event type.Changes to group info is notifying that continuous observer as expected. After which we are fetching group info using observe single event method. But that group info returned is the cached info.
The info returned at reference
database\GroupID1
is always one step old data.Is there anything we are missing here.
Relevant Code:
observer at reference
database\User1
:observe(_ eventType: .value, with block: @escaping (FIRDataSnapshot) -> Swift.Void, withCancel cancelBlock: ((Error) -> Swift.Void)? = nil) -> UInt
observer at reference
database\ GroupID1
:observeSingleEvent(of eventType: .value, andPreviousSiblingKeyWith block: @escaping (FIRDataSnapshot, String?) -> Swift.Void)
The text was updated successfully, but these errors were encountered: