Is it possible to somehow change the query variables for query in progress? My idea is that I'm storing number of showed items in route state with variable called pageSize
. Now when user opens one item and press back button in browser, I will show him exactly the page he has seen before.But route state persist also while refreshed so I want to listen to onReadyStateChange
and if event CACHE_RESTORE_FAILED
will be fired I want to change pageSize
to initial size. Is it possible to somehow listen to this change on Route level?
After @chris comment adding some code:
Route: you can see how I'm getting pageSize from route state
<Route
path=":username"
prepareParams={(params, { location }) => {
const relayParams = params;
if(location.state && location.state.pageSize) {
relayParams.pageSize = location.state && location.state.pageSize;
}
return relayParams;
}}
component={ProductList}
queries={UserQuery}
/>
It's not needed to show any ProductList code, for now it's just rendering of connection. The idea is simple, you open product list page, click on show more few times, and pageSize number is incremented from 20 to 100. User then click on product number 99, i show him product, he click back and he sees who he has seen before. That's great, route state remembered number of times. But after user click refresh in browser, route state is also persisted, so I'm doing query to fetch first 100 products and that's too much. I want to listen to events and if products are not found in local memory ( env has been switched or page refreshed) I want to update variables to fetch only first 20.