Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get response headers in onCacheEntryAdded? #1080

Closed
TamasSzigeti opened this issue May 23, 2021 · 5 comments
Closed

Get response headers in onCacheEntryAdded? #1080

TamasSzigeti opened this issue May 23, 2021 · 5 comments

Comments

@TamasSzigeti
Copy link
Contributor

Hi,

Thanking muchly for this great lib.
I've done some custom implementation of streaming updates in alpha.2, using onSuccess. In my api response I advertise the subscribe url in a http link header, and I have used the meta.response there to get it.
Now I was excited to see first class support for streaming updates but I can see that the meta argument is unavailable in onCacheEntryAdded. Is there any way we could provide it in the callback, or can you recommend a replacement for this behaviour?

TIA

@phryneas
Copy link
Member

Unfortunately, it didn't make it into this beta. It's on the roadmap, which is why the response value of cacheDataLoaded is shaped like { data: ResultType } (so that meta can be added there, too), but it requires bigger adjustments in createAsyncThunk to get this working correctly. I hope we can still get this into the 1.6 release, but I can't give any guarantees yet. Worst case it would be a 1.7 that would have a much shorter release cycle than our last few releases.

@TamasSzigeti
Copy link
Contributor Author

Thanks for the quick response! The problem is that the meta argument in onSuccess is now typed as undefined, so with the beta even my original solution seems to be broken. Is it maybe possible to at least recover the meta there the way it worked in alpha?

@phryneas
Copy link
Member

Unfortunately not, since onSuccess is now just polyfilled using onCacheEntryAdded for migration purposes. But good news: I'm about halfway through the required changes of createAsyncThunk, so assuming everything works out you'll maybe even today have a codesandbox build with meta support. Until that, you'll have stay on the old alpha, sorry!

@TamasSzigeti
Copy link
Contributor Author

That's amazing! Sure, no rush though, the alpha is stable enough and works pretty well with the custom streaming update implementation, I just wanted to make sure I will eventually be able to use the official callbacks. Thanks again!

@markerikson
Copy link
Collaborator

Should be resolved by #1084 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants