We've got a server endpoint that's returning two models (in the example, Apples and Oranges). It makes sense for the server to do the computation in this way, so we ideally don't want to change this response structure. So, image you hit an endpoint /fruits
that returns apples and oranges in a side-loaded fashion. In the example JSBin, we're mocking this response.
So far, so good. However, we want to be able to request Apples or Oranges indepently from the Store (e.g. store.findAll('orange')
or store.findAll('apple')
). We found a way to do this by overriding pathForType
, which works great, but we are double-requesting the data from server when we request Apples and Oranges on the same page. Imagine you were able to swap in different components containing info about Apples or Oranges, and it needs to request itself from the store to ensure we have the data in the store to show the user (or request from the server if we don't have the data