-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
23 seconds to get initial data ? #637
Comments
@daslicht works fine for me. created a quick app and the data got loaded in a second and i followed the documentation as well. did you try the sample example in documentation. how much time does it takes to load the initial data. also you're making a call to firebase in constructor. probably not a best practice. you want to change it something like this.
|
Hi, Have you tried it with my firebase credentials ? Probably I have configured something wrong ion Firebase that it take so long ? I also tried a similar way to you , something like this, but it was as slow as the other approach.
just using
Or do you need to extend the Class somehow ? |
Is there also a way to just extend or? implement the AngularFire Class so that you don't actually need to add it to the App Module but just to the Service. please? |
I created a much simpler example without the Heroes overhead : |
Very strange. If you see the Network tab in Chrome for the frames in WebSocket connection, the data arrives very clicked, but then it's not displayed. Have you tried subscribing to the |
|
|
Hello, I am having a serious issue right now with this as well. I am just doing a simple call as per the documentation. My exact code:
Then in my template:
I have tried to set I also tried to use Thanks |
A possible workaround until we get a official fix is to wrap the return into a https://github.com/daslicht/angular2-firebase/blob/oauth/src/app/app.component.ts#L53 |
I can confirm that FirebaseListObservable is not affected. Just wrote the same function with FirebaseObjectObservable and FirebaseListObservable. The version with FirebaseObjectObservable takes more then 20 sec to load. |
Yes I used the Zone work-around and that fixed the problem with FirebaseObjectObservable. FirebaseListObservable is working as expected. I just ran a test again. Thanks @daslicht and @frankspin89 |
@jwuliger glad to hear that the zone work-around is working for you. Sadly it's not working for me at the moment. Do you mind to share your solution? |
@frankspin89 Sure! Sorry for the late reply. Here is my working component code:
Then is my template this is how I call the properties:
I hope this helps!! |
Thanks @jwuliger for the provided example code. Sadly no improvements on the loading speed here ;-( Here is a piece of my code: Service
Component
Template
Every time I visit the corresponding page it takes around 20 sec to load the data. I see the data instant in my console user: FirebaseObjectObservable |
I have a similar issue that my web app (using angular-cli workflow) takes around 10 - 15 seconds to render the data on the page. However, I see the data instant in my console. I then clone the whole project with a different workflow (not using angular-cli workflow). The problem is gone! I still not make sure if the problem is somewhere from angular-cli or from firebase side |
@frankspin89 No problem for posting. Sorry you are still facing issues. I see you are not using the
Also just out of curiosity, it looks like your data model for your user profile is being set as an array. Have you tried using it as an object? So instead of Also in your service, do you have On a separate note, I found that the code I posted above works in cases where I am lazy loading a module. Any other case I have to go about it differently. Here is an example of the code I use when I am not lazy loading: The Service
The Component
The Template
In this case I don't need to use |
Hey Folks, I'm working on a fix for this. It's actually a simple fix that's been fixed already for some of the auth APIs. I've already created a The crux of the problem is that Firebase's WebSocket listeners are being registered before Angular's zone exists, and thus are patched outside of Angular's zone, so change detection doesn't run when the WebSocket delivers new values. This isn't bad behavior from Firebase, more just a challenge with the way zone.js and Angular's zone are designed. |
@jeffbcross Thanks. I can see the crux and why things have been happening the way they have. |
@jeffbcross that is fantastic news. I just dropped in Auth today and noticed this issue. The timing worked out pretty good. :) That said - do you know if this fix will be apart of the same release for the various typings (for installation) fixes as well? |
@JT-Bruch Yes this is blocking the next release which will contain all fixes that are in master. Do you know of any typings issues that aren't fixed in master? |
Since Firebase is adding WebSocket listeners before the Angular Zone exists, all callbacks when data is received are being executed outside of Angular's zone and are not triggering change detection. This fix uses the existing ZoneScheduler, which is already used in auth.onAuth, to cause the observables created by af.list() and af.object() to be emitted inside the current Zone at the time of calling .list() or .object(). Fixes angular#637
Not sure, I tried about a week ago to get master but was having more typings issues. I figured I'd wait and see as the fix is pretty easy as of right now, and looking at the commit history that was the same change made. Figured the issues I was having was due to the build process. Appreciate all the work y'all put into this. |
Since Firebase is adding WebSocket listeners before the Angular Zone exists, all callbacks when data is received are being executed outside of Angular's zone and are not triggering change detection. This fix uses the existing ZoneScheduler, which is already used in auth.onAuth, to cause the observables created by af.list() and af.object() to be emitted inside the current Zone at the time of calling .list() or .object(). Fixes angular#637
Since Firebase is adding WebSocket listeners before the Angular Zone exists, all callbacks when data is received are being executed outside of Angular's zone and are not triggering change detection. This fix uses the existing ZoneScheduler, which is already used in auth.onAuth, to cause the observables created by af.list() and af.object() to be emitted inside the current Zone at the time of calling .list() or .object(). See angular/angular#4603 for progress on making RxJS more zone-aware. Fixes angular#637
For anyone waiting on an official fix and would like to get the initial data rendered in less than 30 seconds, for the main app to re-render itself after a little under a second or roughly as long as it takes for your first round of data to arrive. This is a horrid hack and I'm slightly ashamed to share :) It just will allow you to continue using angularfire2 as normal without the zone.run() all over the place. In my AppComponent called once to re-render the app: |
The issue also occurs when dealing with RxJS
Where would I need to wrap with zone please? |
@daslicht You probably have to wrap the zone around your
|
hehe , already tried , no luck , thats why I am asking :) |
Working like a champ for me. Thanks @jeffbcross! |
so it has been fixed now ? |
@daslicht Yes, @jeffbcross fixed the issue and released beta.6. Object and list factory now use the zone scheduler. I will upgrade my version later today to see if all my issues related to this topic are fixed. Thanks @jeffbcross for your work! |
Hi,
i have followed the following documentation:
https://github.com/angular/angularfire2/blob/master/docs/2-retrieving-data-as-objects.md
Anything works fine, except that it takes 23 seconds to display the initial data.
If I update the data i see it immediately changed in the firebase console so the connection is good.
Thats my app:
https://daslicht.github.io/Tour-of-Heroes/items
I also tried it hosted on firebase with the same result
That's how I load the data :
https://github.com/daslicht/Tour-of-Heroes/blob/firebase/src/app/items/items.component.ts#L16
What am I missing please ?
The text was updated successfully, but these errors were encountered: