Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
488 views
in Technique[技术] by (71.8m points)

workbox - Setting metadata for a background sync request so I can reconcile it with existing data after sync

We're using workbox background sync to handle retrying requests during patchy network connectivity. After the sync is successful, we want a way to indicate to the user that an action has successfully synced. I'm wondering how we can reconcile our redux state with the sync status.

I've noticed that entries in the workbox background sync queue have a metadata property. This seems ideal for performing the reconciliation as we can theoretically put the entity ID in the metadata. The problem I'm facing is how I can set the metadata when performing the initial request. Currently I'm using the fetch API and assuming that the backgroundsync plugin will intercept failed requests.

I can't see a way to set metadata for a request when using the fetch API. Any suggestions?

https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch

question from:https://stackoverflow.com/questions/65931804/setting-metadata-for-a-background-sync-request-so-i-can-reconcile-it-with-existi

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...