mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 10:20:08 +00:00
added doc to .cache(..)
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
bc96a4df59
commit
18846406ed
@ -440,7 +440,8 @@ module.Logger = ImageGridFeatures.Feature({
|
|||||||
// right at the string start.
|
// right at the string start.
|
||||||
//
|
//
|
||||||
// XXX might be a good idea to move this to a more generic spot like lib/util.js...
|
// XXX might be a good idea to move this to a more generic spot like lib/util.js...
|
||||||
var doc = module.doc = object.doc
|
//var doc = module.doc = object.doc
|
||||||
|
var doc = module.doc = actions.doc
|
||||||
var text = module.text = object.text
|
var text = module.text = object.text
|
||||||
|
|
||||||
|
|
||||||
@ -1045,6 +1046,9 @@ module.Serialization = ImageGridFeatures.Feature({
|
|||||||
// XXX would be nice to have a simple cachedAction(name, cache-tag, expire, func)
|
// XXX would be nice to have a simple cachedAction(name, cache-tag, expire, func)
|
||||||
// action wrapper that would not require anything from the action and
|
// action wrapper that would not require anything from the action and
|
||||||
// just not call it if already called...
|
// just not call it if already called...
|
||||||
|
// ...to do this we'll need to be able to select a value by args
|
||||||
|
// from the cache this will require a diff mattch or something
|
||||||
|
// similar...
|
||||||
var CacheActions = actions.Actions({
|
var CacheActions = actions.Actions({
|
||||||
config: {
|
config: {
|
||||||
// Enable/disable caching...
|
// Enable/disable caching...
|
||||||
@ -1092,38 +1096,42 @@ var CacheActions = actions.Actions({
|
|||||||
// XXX handler cache..
|
// XXX handler cache..
|
||||||
},
|
},
|
||||||
|
|
||||||
// Cache utility method...
|
|
||||||
//
|
|
||||||
// .cache(title, handler)
|
|
||||||
// -> value
|
|
||||||
//
|
|
||||||
// .cache(group, title, handler)
|
|
||||||
// -> value
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Example use:
|
|
||||||
// someAction: [
|
|
||||||
// function(){
|
|
||||||
// return this.cache('someAction',
|
|
||||||
// function(data){
|
|
||||||
// if(data){
|
|
||||||
// // clone/update the data...
|
|
||||||
// // NOTE: this should be faster than the construction
|
|
||||||
// // branch below or this will defeat the purpose
|
|
||||||
// // of caching...
|
|
||||||
// ...
|
|
||||||
//
|
|
||||||
// } else {
|
|
||||||
// // get the data...
|
|
||||||
// ...
|
|
||||||
// }
|
|
||||||
// return data
|
|
||||||
// }) }],
|
|
||||||
//
|
|
||||||
// XXX what should the default group be???
|
|
||||||
// XXX should this be an action???
|
|
||||||
__cache: null,
|
__cache: null,
|
||||||
cache: function(title, handler){
|
cache: doc('Get or set cache value',
|
||||||
|
doc`Get or set cache value
|
||||||
|
|
||||||
|
.cache(title, handler)
|
||||||
|
-> value
|
||||||
|
|
||||||
|
.cache(group, title, handler)
|
||||||
|
-> value
|
||||||
|
|
||||||
|
|
||||||
|
Example use:
|
||||||
|
someAction: [
|
||||||
|
function(){
|
||||||
|
return this.cache('someAction',
|
||||||
|
function(data){
|
||||||
|
if(data){
|
||||||
|
// clone/update the data...
|
||||||
|
// NOTE: this should be faster than the construction
|
||||||
|
// branch below or this will defeat the purpose
|
||||||
|
// of caching...
|
||||||
|
...
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// get the data...
|
||||||
|
...
|
||||||
|
}
|
||||||
|
return data
|
||||||
|
}) }],
|
||||||
|
|
||||||
|
|
||||||
|
NOTE: since this is here to help speed things up, introducing a
|
||||||
|
small but not necessary overhead by making this an action is
|
||||||
|
not logical...
|
||||||
|
`,
|
||||||
|
function(title, handler){
|
||||||
var group = 'global'
|
var group = 'global'
|
||||||
// caching disabled...
|
// caching disabled...
|
||||||
if(!(this.config || {}).cache){
|
if(!(this.config || {}).cache){
|
||||||
@ -1136,7 +1144,7 @@ var CacheActions = actions.Actions({
|
|||||||
title in cache ?
|
title in cache ?
|
||||||
// pass the cached data for cloning/update to the handler...
|
// pass the cached data for cloning/update to the handler...
|
||||||
handler.call(this, cache[title])
|
handler.call(this, cache[title])
|
||||||
: handler.call(this)) },
|
: handler.call(this)) }),
|
||||||
clearCache: ['System/Clear cache',
|
clearCache: ['System/Clear cache',
|
||||||
doc`
|
doc`
|
||||||
|
|
||||||
|
|||||||
8
Viewer/package-lock.json
generated
8
Viewer/package-lock.json
generated
@ -1073,11 +1073,11 @@
|
|||||||
"integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg=="
|
"integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg=="
|
||||||
},
|
},
|
||||||
"ig-actions": {
|
"ig-actions": {
|
||||||
"version": "3.24.18",
|
"version": "3.24.19",
|
||||||
"resolved": "https://registry.npmjs.org/ig-actions/-/ig-actions-3.24.18.tgz",
|
"resolved": "https://registry.npmjs.org/ig-actions/-/ig-actions-3.24.19.tgz",
|
||||||
"integrity": "sha512-0cZYX56el81rOGcD/GwFsrD4pRg3ZwYu7ilSzkXhZTw+mvGQD7Vilj1faHrWTX2geMS3XugZ/294dP/Jl6VGDg==",
|
"integrity": "sha512-b4Lz4qD/aw7MOcNDgGn/y6992EjeFHQw6tmv1AfX1ZeWdpg9TjPjkdFy5NLpdGknURM/b1I06AkxYLgBAeOQyQ==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"ig-object": "^5.0.2"
|
"ig-object": "^5.4.12"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ig-argv": {
|
"ig-argv": {
|
||||||
|
|||||||
@ -28,7 +28,7 @@
|
|||||||
"generic-walk": "^1.4.0",
|
"generic-walk": "^1.4.0",
|
||||||
"glob": "^7.1.6",
|
"glob": "^7.1.6",
|
||||||
"guarantee-events": "^1.0.0",
|
"guarantee-events": "^1.0.0",
|
||||||
"ig-actions": "^3.24.18",
|
"ig-actions": "^3.24.19",
|
||||||
"ig-argv": "^2.15.0",
|
"ig-argv": "^2.15.0",
|
||||||
"ig-features": "^3.4.2",
|
"ig-features": "^3.4.2",
|
||||||
"ig-object": "^5.4.12",
|
"ig-object": "^5.4.12",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user