data icon indicating copy to clipboard operation
data copied to clipboard

Pre-RFC: Multiplex Requests

Open runspired opened this issue 1 year ago • 0 comments

Currently, requests triggered around the same time (for instance by multiple components or routes) will resolve as soon as their data is received and process.

This can lead to a lot of extraneous churn in application state.

Sometimes applications can multiplex promises themselves using RSVP.hash or RSVP.all; however, this is not always the case. A smarter router could also multiplex across routes. This feature would bridge the gap for applications for which a smarter router is not available.

We should consider adding a mechanism to request specific to multiplexing. Multiplexed requests would exhibit two key behaviors differing from non-multiplexed requests.

  1. Their promises would not resolve until they all can resolve, meaning that they resolve within a single microtask queue.

  2. The updates they push to the cache would not notify the UI of any changes until all multiplexed requests have completed.

Roughly the API would look like this

store.request({
  url: 'my-url',
  cacheOptions: {
    multiplex: true
  }
});

Once a multiplexed request begins, no requests may resolve until it resolves. This means that requests that the longest request specifying multiplexing is the one which determines when request resolution occurs.

runspired avatar Sep 10 '23 07:09 runspired