Skip to content
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

Introduce availability of wp.hooks in service worker #142

Open
westonruter opened this issue Mar 16, 2019 · 3 comments
Open

Introduce availability of wp.hooks in service worker #142

westonruter opened this issue Mar 16, 2019 · 3 comments
Assignees

Comments

@westonruter
Copy link
Collaborator

In order to facilitate themes and plugins to perform manipulations in the service worker,

There is code in service-worker-navigation-routing.js and service-worker-offline-commenting.js that could benefit from hook extensibility (among other scripts).

For example, instead of there being one single navigation caching strategy registered for every URL which is then used in the the service worker:

https://github.com/xwp/pwa-wp/blob/a66f599fc27c7c0e2d85e649d8b4831a009ce1a4/wp-includes/js/service-worker-navigation-routing.js#L138

The CACHING_STRATEGY and CACHING_STRATEGY_ARGS could be filtered, with the event passed to the filter to decide dynamically what the caching strategy should be.

I'm sure there are plenty of other cases where filtering in JS would give the flexible extensibility that would be required.

@adamsilverstein
Copy link
Collaborator

This is certainly a great use case for wp.hooks and will be a familiar approach to WordPress developers. @westonruter - would introducing a single filter here be sufficient to resolve this issue?

I'm sure there are plenty of other cases where filtering in JS would give the flexible extensibility that would be required.

New the codebase here, can you clarify what other areas you think will benefit from additional JS extensibility?

@westonruter
Copy link
Collaborator Author

The use case I see having immediate benefit is using the filter for plugins to be able to dynamically modify the content of the offline page, such as injecting a list of links that are available offline. So I'd start exploring that in #211.

@westonruter
Copy link
Collaborator Author

Started playing around with this in #234.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants