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?
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.Like this.
Thank you for the help :)