cachee
Cachee is a simple library that helps developer cache resources and requests and reuse them during a long lived application. That way if the app looses connectivity during usage the user will not experience any problems
Install
bower install --save cachee
Usage
<!-- Format: --><!-- <tag-name cachee="<attr>:<resource-url>"></tag-name> -->
Documentation
object
cachee : A namespace that holds methods to help cache data inside blob urls
Kind: global namespace
- cachee :
object
- .cache(cacheRequests) ⇒
Promise
- .load([elem])
- .request(opt) ⇒
Promise
- .resource(url, opt) ⇒
Promise
- .readResource(url, [type]) ⇒
Promise
- .writeResource(id, content, [mimeType]) ⇒
Promise
- .deleteResource(id)
- .$$(context, selector) ⇒
Array
- .cache(cacheRequests) ⇒
Promise
cachee.cache(cacheRequests) ⇒ cache resource requests
Kind: static method of cachee
Param | Type | Description |
---|---|---|
cacheRequests | Array |
list of chache requests |
Example
<!-- Format: --><!-- <tag-name cachee="<attr>:<resource-url>"></tag-name> --><img cachee="src:/my-resource1" /><img cachee="src:/my-resource2" /><img cachee="src:/my-resource3" /><img cachee="src:custom-resource" /> <script> cachee;</script> <!-- Using deep attribute set and template attribute --><!-- Format --><!-- <tag-name cachee-tpl="my url resource ${<attr>}" cachee="<attr>:<resource-url"></tag-name> --><div cachee="style.backgroundImage:/my-resource1" cachee-tpl="url(${style.backgroundImage})"></div> <script> cachee;</script>
cachee.load([elem])
load specfic resources
Kind: static method of cachee
Param | Type | Default | Description |
---|---|---|---|
[elem] | Element |
document |
root element or document |
Promise
cachee.request(opt) ⇒ send an http request
Kind: static method of cachee
Param | Type |
---|---|
opt | Object |
Example
//get requestcachee; // post requestcachee;
Promise
cachee.resource(url, opt) ⇒ Sends a resource request and if the resource is not in cache it will cache it and retun it's blob url
Kind: static method of cachee
Param | Type | Description |
---|---|---|
url | String |
resource url |
opt | Object |
http request options |
Promise
cachee.readResource(url, [type]) ⇒ Reads a resource and returns a specific type
Kind: static method of cachee
Param | Type | Default | Description |
---|---|---|---|
url | String |
the resource url | |
[type] | String |
"text" |
http compliant responseType string |
Example
cachee;
Promise
cachee.writeResource(id, content, [mimeType]) ⇒ Write a resource to the cache table
Kind: static method of cachee
Returns: Promise
- the blob url in a promise
Param | Type | Default | Description |
---|---|---|---|
id | String |
unique identifyer | |
content | Mixed |
the resource content | |
[mimeType] | String |
"text/plain" |
the resource's mime type |
Example
cachee; // reading the resource cachee;
cachee.deleteResource(id)
removes a resource form cache
Kind: static method of cachee
Param | Type |
---|---|
id | String |
Example
cachee;...// delete the resource after we are done with itcachee;
Array
cachee.$$(context, selector) ⇒ Dom helper method
Kind: static method of cachee
Param | Type |
---|---|
context | Element |
selector | String |
Example
cachee;
Contribution
Pull requests, Bug reports and feature requests