add sync/async mode pass through for tasks...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2020-11-27 02:33:46 +03:00
parent 7f086b289b
commit 84809a0e24
4 changed files with 32 additions and 8 deletions

View File

@ -2366,13 +2366,35 @@ function(func){
// ExampleActions.exampleTask(..)
// 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 =
module.taskAction =
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
return (action = object.mixin(
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,
toString: function(){

View File

@ -861,8 +861,7 @@ module.Sharp = core.ImageGridFeatures.Feature({
// XXX this is best done in a thread + needs to be abortable (on .load(..))...
[['loadImages',
'loadNewImages'],
function(){
this.cacheMetadata('all') }],
'cacheMetadata: "all"'],
//*/
// set orientation if not defined...
@ -879,8 +878,11 @@ module.Sharp = core.ImageGridFeatures.Feature({
var that = this
// NOTE: as this directly affects the visible lag, this
// 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.cacheMetadata(gid, false)
|| this.cacheMetadata('sync', gid, false)
.then(function([res]){
res
&& that.logger

View File

@ -1110,9 +1110,9 @@
"integrity": "sha512-9kZM80Js9/eTwXN9VXwLDC1wDJ7gIAdYU9GIzb5KJmNcLAMaW+zhgFrwFFMrcSfggUuadgnqSrS41E4XLe8JZw=="
},
"ig-types": {
"version": "5.0.17",
"resolved": "https://registry.npmjs.org/ig-types/-/ig-types-5.0.17.tgz",
"integrity": "sha512-A4qzL3t+usOnPx7tu+ieUDQIDUBEocouv7O6aBbLTcleDM5VNDOrdswfThNk3PSoP1bTSLmQV9LWsBRG1qVXiA==",
"version": "5.0.18",
"resolved": "https://registry.npmjs.org/ig-types/-/ig-types-5.0.18.tgz",
"integrity": "sha512-8c16slG/J0qC9oYW1Mx6oSriEYKEY/HLs4SvgWDLqac/qx/nMaa6HlEUA/fi+whGxvTk03t4s/IKca+MKWV9oQ==",
"requires": {
"ig-object": "^5.4.12",
"object-run": "^1.0.1"

View File

@ -32,7 +32,7 @@
"ig-argv": "^2.15.0",
"ig-features": "^3.4.2",
"ig-object": "^5.4.12",
"ig-types": "^5.0.17",
"ig-types": "^5.0.18",
"moment": "^2.29.1",
"object-run": "^1.0.1",
"requirejs": "^2.3.6",