mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 18:30:09 +00:00
add sync/async mode pass through for tasks...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
7f086b289b
commit
84809a0e24
@ -2366,13 +2366,35 @@ function(func){
|
|||||||
// ExampleActions.exampleTask(..)
|
// ExampleActions.exampleTask(..)
|
||||||
// ExampleActions.exampleSessionTask(..)
|
// ExampleActions.exampleSessionTask(..)
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// NOTE: we can pass sync/async to this in two places, in definition:
|
||||||
|
// var action = taskAction('some title', 'sync', function(..){ .. })
|
||||||
|
// or
|
||||||
|
// var action = taskAction('sync', 'some title', function(..){ .. })
|
||||||
|
//
|
||||||
|
// and on call:
|
||||||
|
// action('sync', ..)
|
||||||
|
//
|
||||||
|
// during the later form 'sync' is passed to .Task(..) in the correct
|
||||||
|
// position...
|
||||||
|
// (see ig-types' runner.TaskManager(..) for more info)
|
||||||
var taskAction =
|
var taskAction =
|
||||||
module.taskAction =
|
module.taskAction =
|
||||||
function(title, func){
|
function(title, func){
|
||||||
|
var pre_args = [...arguments]
|
||||||
|
func = pre_args.pop()
|
||||||
|
title = pre_args
|
||||||
|
.filter(function(t){
|
||||||
|
return t != 'sync' && t != 'async' })
|
||||||
|
.pop()
|
||||||
|
|
||||||
var action
|
var action
|
||||||
return (action = object.mixin(
|
return (action = object.mixin(
|
||||||
Task(function(...args){
|
Task(function(...args){
|
||||||
return this.tasks.Task(title, func.bind(this), ...args) }),
|
if(args[0] == 'sync' || args[0] == 'async'){
|
||||||
|
pre_args = [args.shift(), title] }
|
||||||
|
return this.tasks.Task(...pre_args, func.bind(this), ...args) }),
|
||||||
{
|
{
|
||||||
__task_title__: title,
|
__task_title__: title,
|
||||||
toString: function(){
|
toString: function(){
|
||||||
|
|||||||
@ -861,8 +861,7 @@ module.Sharp = core.ImageGridFeatures.Feature({
|
|||||||
// XXX this is best done in a thread + needs to be abortable (on .load(..))...
|
// XXX this is best done in a thread + needs to be abortable (on .load(..))...
|
||||||
[['loadImages',
|
[['loadImages',
|
||||||
'loadNewImages'],
|
'loadNewImages'],
|
||||||
function(){
|
'cacheMetadata: "all"'],
|
||||||
this.cacheMetadata('all') }],
|
|
||||||
//*/
|
//*/
|
||||||
|
|
||||||
// set orientation if not defined...
|
// set orientation if not defined...
|
||||||
@ -879,8 +878,11 @@ module.Sharp = core.ImageGridFeatures.Feature({
|
|||||||
var that = this
|
var that = this
|
||||||
// NOTE: as this directly affects the visible lag, this
|
// NOTE: as this directly affects the visible lag, this
|
||||||
// must be as fast as possible...
|
// must be as fast as possible...
|
||||||
|
// NOTE: running .cacheMetadata(..) in sync mode here forces
|
||||||
|
// the image to update before it gets a change to be
|
||||||
|
// drawn...
|
||||||
;((this.images[gid] || {}).metadata || {}).ImageGridMetadata
|
;((this.images[gid] || {}).metadata || {}).ImageGridMetadata
|
||||||
|| this.cacheMetadata(gid, false)
|
|| this.cacheMetadata('sync', gid, false)
|
||||||
.then(function([res]){
|
.then(function([res]){
|
||||||
res
|
res
|
||||||
&& that.logger
|
&& that.logger
|
||||||
|
|||||||
6
Viewer/package-lock.json
generated
6
Viewer/package-lock.json
generated
@ -1110,9 +1110,9 @@
|
|||||||
"integrity": "sha512-9kZM80Js9/eTwXN9VXwLDC1wDJ7gIAdYU9GIzb5KJmNcLAMaW+zhgFrwFFMrcSfggUuadgnqSrS41E4XLe8JZw=="
|
"integrity": "sha512-9kZM80Js9/eTwXN9VXwLDC1wDJ7gIAdYU9GIzb5KJmNcLAMaW+zhgFrwFFMrcSfggUuadgnqSrS41E4XLe8JZw=="
|
||||||
},
|
},
|
||||||
"ig-types": {
|
"ig-types": {
|
||||||
"version": "5.0.17",
|
"version": "5.0.18",
|
||||||
"resolved": "https://registry.npmjs.org/ig-types/-/ig-types-5.0.17.tgz",
|
"resolved": "https://registry.npmjs.org/ig-types/-/ig-types-5.0.18.tgz",
|
||||||
"integrity": "sha512-A4qzL3t+usOnPx7tu+ieUDQIDUBEocouv7O6aBbLTcleDM5VNDOrdswfThNk3PSoP1bTSLmQV9LWsBRG1qVXiA==",
|
"integrity": "sha512-8c16slG/J0qC9oYW1Mx6oSriEYKEY/HLs4SvgWDLqac/qx/nMaa6HlEUA/fi+whGxvTk03t4s/IKca+MKWV9oQ==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"ig-object": "^5.4.12",
|
"ig-object": "^5.4.12",
|
||||||
"object-run": "^1.0.1"
|
"object-run": "^1.0.1"
|
||||||
|
|||||||
@ -32,7 +32,7 @@
|
|||||||
"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",
|
||||||
"ig-types": "^5.0.17",
|
"ig-types": "^5.0.18",
|
||||||
"moment": "^2.29.1",
|
"moment": "^2.29.1",
|
||||||
"object-run": "^1.0.1",
|
"object-run": "^1.0.1",
|
||||||
"requirejs": "^2.3.6",
|
"requirejs": "^2.3.6",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user