{"id":16696428,"url":"https://github.com/adaliszk/sw-periodic-sync","last_synced_at":"2025-10-11T18:51:02.143Z","repository":{"id":58237946,"uuid":"64327644","full_name":"adaliszk/sw-periodic-sync","owner":"adaliszk","description":"Just a \"polyfill\" solution for the serviceWorker periodicSync, it does the functionallity of the non-standard specification.","archived":false,"fork":false,"pushed_at":"2016-09-27T08:28:09.000Z","size":15,"stargazers_count":13,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-10T02:16:07.375Z","etag":null,"topics":["polyfill","serviceworker","serviceworker-periodicsync"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adaliszk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-07-27T17:16:48.000Z","updated_at":"2020-04-14T19:55:17.000Z","dependencies_parsed_at":"2022-08-31T01:50:48.670Z","dependency_job_id":null,"html_url":"https://github.com/adaliszk/sw-periodic-sync","commit_stats":null,"previous_names":["adamos42/swperiodicsync"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adaliszk%2Fsw-periodic-sync","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adaliszk%2Fsw-periodic-sync/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adaliszk%2Fsw-periodic-sync/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adaliszk%2Fsw-periodic-sync/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adaliszk","download_url":"https://codeload.github.com/adaliszk/sw-periodic-sync/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248142906,"owners_count":21054671,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["polyfill","serviceworker","serviceworker-periodicsync"],"created_at":"2024-10-12T17:28:30.779Z","updated_at":"2025-10-11T18:50:57.078Z","avatar_url":"https://github.com/adaliszk.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# serviceWorker Periodic Synchronization\nJust a \"polyfill\" solution for the serviceWorker periodicSync. This code adding to the ServiceWorkerRegistration object\nprototype the periodicSync method if not available.\n\nThis code is not complete yet, I just created and tested as a possible solution but I need to add moarh code for true\n\"polyfill\" solution. I accept pull request if you have time and like this until the platform does it a better way!\n\n### Sample usage when registering serviceWorker\n\n```\nnavigator.serviceWorker.register('serviceWorker.js').then(swRegistration =\u003e {\n\tswRegistration.periodicSync.register({\n\t\ttag: 'something',\n\t\tpowerState: 'auto',\n\t\tnetworkState: 'online',\n\t\tallowOnBattery: true,\n\t\tidleRequired: false,\n\t\tmaxDelay: 60000,\n\t\tminDelay: 5000,\n\t\tminPeriod: 20000\n\t});\n});\n```\n\n### Sample usage after registering serviceWorker\n```\nnavigator.serviceWorker.ready.then(swRegistration =\u003e {\n\tswRegistration.periodicSync.register({\n\t\ttag: 'something',\n\t\tpowerState: 'auto',\n\t\tnetworkState: 'online',\n\t\tallowOnBattery: true,\n\t\tidleRequired: false,\n\t\tmaxDelay: 60000,\n\t\tminDelay: 5000,\n\t\tminPeriod: 20000\n\t});\n});\n```\n\n### Synchronization event\nWhen the periodicSync is fired the script will trigger a global event which is named after the registered periodic sync\nin this format: ``sync-\u003ctag\u003e``\n```\ndocument.addEventListener('sync-something', function(event) {\n\t// do stuff...\n});\n```\n\n### Unregister a synchronization\n```\nnavigator.serviceWorker.ready.then(swRegistration =\u003e {\n\tswRegistration.periodicSync.getRegistration('something').then(registration =\u003e {\n\t\tregistration.unregister();\n\t});\n});\n```\n\n### Change a synchronization\nThe register will always delete the previnous synchronization settings and use the new one using the tag as a key.\n\n## \"Documentation\"\n* https://developer.mozilla.org/en-US/docs/Web/API/PeriodicSyncManager\n* https://developer.mozilla.org/en-US/docs/Web/API/PeriodicSyncRegistration\n* https://developer.mozilla.org/en-US/docs/Web/API/PeriodicSyncEvent\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadaliszk%2Fsw-periodic-sync","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadaliszk%2Fsw-periodic-sync","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadaliszk%2Fsw-periodic-sync/lists"}