From ef38ca13fa139ebeea2aa863841b5743b2528598 Mon Sep 17 00:00:00 2001 From: Florent Morselli Date: Sat, 9 Mar 2024 09:27:31 +0100 Subject: [PATCH] Prefetch on demand --- assets/src/prefetch-on-demand_controller.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/assets/src/prefetch-on-demand_controller.js b/assets/src/prefetch-on-demand_controller.js index dec4928..477adc7 100644 --- a/assets/src/prefetch-on-demand_controller.js +++ b/assets/src/prefetch-on-demand_controller.js @@ -4,20 +4,16 @@ import { Controller } from '@hotwired/stimulus'; /* stimulusFetch: 'lazy' */ export default class extends Controller { - static values = { - urls: { type: Array, default: []} - }; - - connect = () => { + prefetch = ({params}) => { const workbox = window.workbox; - if (!workbox) { + if (!workbox || !params.urls) { return; } workbox.messageSW({ "type": "PREFETCH", "payload": { - "urls": this.urlsValue + "urls": params.urls } }); }