-
Notifications
You must be signed in to change notification settings - Fork 830
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
Add requestDidReplay callback to BackgroundSync Queue (#1502) #1503
Conversation
35b2d05
to
05d6fdc
Compare
Thanks @Toilal for the explanation in #1502. However, from the use case you described, it sounds like the proposed changes still might not work for you. The changes you've submitted allows for modifying requests, but it doesn't allow for inserting requests into the queue before making further requests. Is that going to be a problem for you? At the moment you can add new requests via the |
To implement the use case in #1502, when a requests fail, we have to set a global It seems like a hack, it's sad that the API is not more opened to implement this use case properly. |
@Toilal I agree, which is why I wanted to make sure your use case was being met before just merging this change. When we designed this API, we didn't have a lot of use cases in mind, so I'm happy to rework it to make it more flexible. Do you have any ideas? One option -- which would be the most flexible but also the biggest pain for users to implement -- is to provide raw access to the request queue. This would allow users to manually retry all requests however they way, and if any fail they can then manually add them back to the queue. What do you think? |
To cover more real use cases.
queue.forEach((request) => doMutate(request)) |
I allow myself to suggest an idea that goes through my mind:
Of course, this example is for code 401 but it can be adapted for any code (>= 400 ?) |
Totally agree with you. @Toilal |
Since this work is approved, can this be merged soon? |
dc69b83
to
5aedcbb
Compare
I have rebased this pull request on current master version (3.6.2), and all checks are now OK. Please consider merging this one. I'm using it since months at it may solve many use cases. |
Hey all, we're going to address this issue as part of our next major release (since it may affect the public API). We're still exploring whether this PR is sufficient or whether it requires a larger change to handle some of the use cases we've seen. |
Hi everyone. I have a simple case and I am not sure the next release will help. For example, I have a get request to get data and a post request to send the data to server. The post request needs the data from the get request. To my understanding, I can implement it with callback or promises when it is online. But I just wondering if the workbox-background-sync(Next release) can queue them together and run behind when the connection is back. |
@WadeFanyao I've done it using the If you didn't understand, no worry, it's because it's awful. |
Hey all, I'm submitted #1710, which I believe will address all of the use cases discussed here. Please take a look at that PR and let me know what you think. |
Closing in favor of #1710. |
R: @jeffposnick @philipwalton
Fixes #1502
Adds
requestDidReplay
andqueueWillReplay
callback