loading...

re: Building a news feed with Firebase VIEW POST

TOP OF THREAD FULL DISCUSSION
re: Yep, my current implementation is already in O(1) since posts from the users a user is following is stored on a their "timeline" field where posts ...

posts from the users a user is following is stored on a their "timeline" field where posts are referenced through their IDs

If the client needs to do an additional "Find Post By ID" call for each ID referenced in the timeline list, then the function getMyTimelinePosts() would be at least O(n). The way around this is to "fan out" copies of the full posts into each user's timeline object. When you make that first call, everything you need for the timeline will be in the response - no additional calls are necessary. Here is another article that helps explain it.

Any way I can cache the existing data so the app shows the cached data on initial load, and then loads in the "new" data once that's ready?

Like this.

Thank you for the help :)

code of conduct - report abuse