title: Can i subscribe to filtered RTK query data results across multiple components?
body: <p>I have a series of components which all use data derived from an RTK Query response. While derived from the same response with the same query arguments, each component needs the data to pass through a set of relatively expensive client-side filters (whose args are redux store slice properties) which may not be the same for each component. However, all of the components require the data to pass through at least two specific filters. This relationship is shown by the following diagram:</p>
  <p>Is it possible to subscribe to the data <em>after</em> it has been transformed by a specific filter/ set of filters?</p>
  <p><a href="https://i.stack.imgur.com/fxxK5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fxxK5.png" alt="enter image description here" /></a></p>
  <p>Approaches I have considered:</p>
  <ul>
  <li>Use query in all components, apply whichever filters are required in some useEffect or useMemo. This is not preferable since that means at least 2 filters are being duplicated nComponents times.</li>
  <li>Use createSlice <code>extraReducers</code> option and listen for query completion, then perform filter operation. This works fine since i can use the filter args in the reducer, but I believe there is no way for me to repeat the operation with new args once the filter args have been updated but the query data has stayed the same.</li>
  <li>Subscribe one component, publish data to slice after each corresponding filter stage,
  subscribe each component to corresponding data. This is how i currently have this implemented, but it is not ideal because it couples components together which i wish to avoid, bloats one component which is sort of arbitrarily chosen, and produces frequent large state actions which slow down my application.</li>
  <li>Raise query subscription to shared ancestor component, then pass data as props. This is not ideal because these components are at varying depths relative to their shared ancestor, which I imagine would result in prop drilling for at least some component.</li>
  <li>Use react context to share results of first 2 filter operations with corresponding components. Haven't looked into this much yet; would it work with a query subscription?</li>
  </ul>
  <p>Intuitively i would think some callback that operates as some middleware between the API result and the component's subscribed data would be ideal. I am aware of the transformResponse option definable in the API slice, but I believe it is not appropriate or possible for this situation.</p>
  <pre><code>const queryResult = endpointName.useQuery(args, filterArgs, (data, filterArgs) =&gt; {
      return data.performSomeSharedFilterOperationHere(filterArgs);
      } 
  );
  </code></pre>
  <p>Ideally the data would update when query args change OR when filter args change. I suppose the difference between this and a simple useEffect implementation is that in the useEffect scenario, the data is not 'shared' and the filter operations occur nSubscribedComponents times.</p>
  <p>Is there anything in RTK that permits the behavior I am seeking?</p>