This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//After install, fetch event is triggered for every page request | |
self.addEventListener("fetch", function (event) { | |
console.log("Request -->", event.request.url); | |
//To tell browser to evaluate the result of event | |
event.respondWith( | |
caches.match(event.request) //To match current request with cached request it | |
.then(function(response) { | |
//If response found return it, else fetch again. | |
return response || fetch(event.request); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let _singleton = Symbol(); | |
class Singleton { | |
constructor(singletonToken) { | |
if (_singleton !== singletonToken) | |
throw new Error('Cannot instantiate directly.'); | |
} | |
static get instance() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
<a href="posts/2" data-method="delete"> <---- We want to send an HTTP DELETE request | |
- Or, request confirmation in the process - | |
<a href="posts/2" data-method="delete" data-confirm="Are you sure?"> | |
Add this to your view: | |
<script> | |
window.csrfToken = '<?php echo csrf_token(); ?>'; |