You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I need a callback requestDidReplay invoked after each replay response to read the effective response from the API before the next request is handled.
Description of the use case
Consider a simple CRUD REST API server. The user can create an object and then modify it, regardless he is online or offline, from the webapp.
When he's online, 2 REST API calls are done, and the server generates an id on POST (first call)
POST /api/object (API server generates an id=1337) PUT /api/object/1337
When he's offline, Service Worker and background-sync module save requests into a Queue, but the id is generated by ServiceWorker instead of API.
POST /api/object => The ServiceWorker generates a local temporary negative id=-1, and this requests is queued. PUT /api/object/-1 => The following update request is also queued with it's temporary id.
When user is back online, those requests can be replayed, but we have to read the API server response from POST request to get the database id generated by the server, and replace it into PUT request before replaying it.
This can't be done without introducting a new requestDidReplay callback. (requestWillReplay and a global object to store ids mapping will also be used).
The text was updated successfully, but these errors were encountered:
Toilal
added a commit
to Toilal/workbox
that referenced
this issue
May 28, 2018
Library Affected:
workbox-background-sync
Browser & Platform:
"all browsers"
Feature Request Description:
This followup: #868 (comment)
I need a callback
requestDidReplay
invoked after each replay response to read the effective response from the API before the next request is handled.Description of the use case
Consider a simple CRUD REST API server. The user can create an object and then modify it, regardless he is online or offline, from the webapp.
When he's online, 2 REST API calls are done, and the server generates an id on
POST
(first call)POST /api/object
(API server generates anid=1337
)PUT /api/object/1337
When he's offline, Service Worker and background-sync module save requests into a Queue, but the id is generated by ServiceWorker instead of API.
POST /api/object
=> The ServiceWorker generates a local temporary negativeid=-1
, and this requests is queued.PUT /api/object/-1
=> The following update request is also queued with it's temporary id.When user is back online, those requests can be replayed, but we have to read the API server response from
POST
request to get the database id generated by the server, and replace it intoPUT
request before replaying it.This can't be done without introducting a new
requestDidReplay
callback. (requestWillReplay
and a global object to store ids mapping will also be used).The text was updated successfully, but these errors were encountered: