/
CacheStorage.cljs
88 lines (66 loc) · 2.89 KB
/
CacheStorage.cljs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
(ns web.service-workers.CacheStorage
"The CacheStorage interface represents the storage for `web.service-workers.Cache`"
(:refer-clojure :exclude [keys]))
(defn match
"Method.
The match() method of the `web.service-workers.CacheStorage`
(available globally as caches) checks if a given `web.fetch.Request`
url string is a key for a stored `web.fetch.Response`. This method
a `js.Promise` for a `web.fetch.Response`, or undefined if no
is found.
`caches.match(request, options).then(function(response) {
// Do something with the response
});`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/CacheStorage/match`"
[this & args]
(apply (-> this .-match) (concat [this] args)))
(defn delete
"Method.
The delete() method of the `web.service-workers.CacheStorage`
finds the `web.service-workers.Cache` object matching the cacheName,
if found, deletes the `web.service-workers.Cache` object and
a `js.Promise` that resolves to true. If no `web.service-workers.Cache`
is found, it returns false.
`caches.delete(cacheName).then(function(boolean) {
// your cache is now deleted
});`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/CacheStorage/delete`"
[this & args]
(apply (-> this .-delete) (concat [this] args)))
(defn has
"Method.
The has() method of the `web.service-workers.CacheStorage` interface
a `js.Promise` that resolves to true if a `web.service-workers.Cache`
matches the cacheName.
`caches.has(cacheName).then(function(boolean) {
// true: your cache exists!
});`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/CacheStorage/has`"
[this & args]
(apply (-> this .-has) (concat [this] args)))
(defn keys
"Method.
The keys() method of the `web.service-workers.CacheStorage` interface
a `js.Promise` that will resolve with an array containing strings
to all of the named `web.service-workers.Cache` objects tracked
the `web.service-workers.CacheStorage` object in the order they
created. Use this method to iterate over a list of all `web.service-workers.Cache`
`caches.keys().then(function(keyList) {
//do something with your keyList
});`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/CacheStorage/keys`"
[this & args]
(apply (-> this .-keys) (concat [this] args)))
(defn open
"Method.
The open() method of the `web.service-workers.CacheStorage` interface
a `js.Promise` that resolves to the `web.service-workers.Cache`
matching the cacheName.
`// \\\"caches\\\" is a global read-only variable, which is an instance of CacheStorage,
// For more info, refer to: https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/caches
caches.open(cacheName).then(function(cache) {
// Do something with your cache
});`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/CacheStorage/open`"
[this & args]
(apply (-> this .-open) (concat [this] args)))