[best practice] Chained API requests

Any time I have nested futures, I’m uncomfortable.

“Need”? No, but that’s definitely where I would do this task. The rest of this post, however, assumes that we’re still doing everything client-side.

That depends on who can share what. If everything is 1-to-1, meaning that each user has exactly one address, one phone number, and no users can share any of those things, then I don’t see the point in having them in separate tables. We’re still going to leave that alone, and address how to do this most cleanly in RxJS.

Some heuristics I use here:

  • no any
  • everything is functional, no external state (this means that inside getPosts, this is read-only)
  • no nested subscriptions
  • no subscribing in the place we generate the future (meaning no subscribe in our service at all)

The basic technique for flattening your structure is outlined in this post.