Problem/Motivation

Only one service worker can be registered as top level scoped service worker and there are plenty of reasons why a service worker may want to be the top level service worker. Currently the service worker does everything and is pretty rigid in how it does so.

Steps to reproduce

Proposed resolution

The service worker should be adjusted so that we can create some sort of plugins. These plugins are currently proposed for the "push" handler and the "notification click" handler.

The push handler type is specified by the server sending the push notification. The notification click handler is specified by the push handler.

By using a lookup table in the service worker and routing the events according to the selected type we can easily extend the service worker by concatenating extra scripts into the service worker that register new push or notification click handlers.

Remaining tasks

User interface changes

API changes

Data model changes

Comments

Kingdutch created an issue. See original summary.

kingdutch’s picture

Assigned: kingdutch » Unassigned
Status: Active » Closed (works as designed)

With the latest updates to the module the Service Worker script is nicely loaded through the ServiceWorkerController for the social_pwa.service-worker route. This means that if other modules want to replace the included service worker they can already overwrite the controller for that route. No special code for this are needed.

kingdutch’s picture

Title: Add the ability to swap out the service worker implementation » Allow the service worker to be extended by other modules
Assigned: Unassigned » kingdutch
Issue summary: View changes
Status: Closed (works as designed) » Active

  • Kingdutch committed 139b8d0 on 8.x-1.x
    Issue #3204094 by Kingdutch: Allow the service worker to be extended by...
kingdutch’s picture

Assigned: kingdutch » Unassigned
Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.