Prechádzať zdrojové kódy

Going deeper into the async rabbit hole

Artur Paikin 9 rokov pred
rodič
commit
3b546fd247
3 zmenil súbory, kde vykonal 19 pridanie a 12 odobranie
  1. 17 10
      src/core/Transloadit.js
  2. 1 1
      src/plugins/DragDrop.js
  3. 1 1
      src/plugins/Tus10.js

+ 17 - 10
src/core/Transloadit.js

@@ -60,11 +60,12 @@ export default class Transloadit {
 
     // plugins.push(plugin.run.bind(plugin));
 
-    var pluginTypePack = [];
-    // function dummy(cb) {
-    //   cb(null, 'smth');
-    // }
-    // pluginTypePack.push(dummy);
+    var pluginTypePacks = [];
+    function dummy(cb) {
+      cb(null, 'smth');
+    }
+    // pluginTypePacks.push(async.value([]));
+    pluginTypePacks.push(dummy);
 
     for (let j in this.types) {
       const type = this.types[j];
@@ -75,18 +76,24 @@ export default class Transloadit {
         pluginPack.push(plugin.run.bind(plugin));
       }
       // console.log(pluginPack);
-      const pluginTypePackExecuter = function (done) {
+
+      // async.parallel(pluginPack, function (err, files) {
+      //   // console.log('parallel done');
+      //   console.log(files);
+      //   // done(files);
+      // });
+      const pluginTypePackExecuter = function (files, done) {
         async.parallel(pluginPack, function (err, files) {
           // console.log('parallel done');
-          console.log(files);
+          // console.log(files);
           done(files);
         });
       };
-      pluginTypePack.push(pluginTypePackExecuter);
+
+      pluginTypePacks.push(pluginTypePackExecuter);
     }
-    // console.log(pluginTypePack);
 
-    async.waterfall(pluginTypePack, function (result) {
+    async.waterfall(pluginTypePacks, function (result) {
       // console.log(result);
     });
 

+ 1 - 1
src/plugins/DragDrop.js

@@ -48,7 +48,7 @@ export default class DragDrop extends TransloaditPlugin {
     return files;
   }
 
-  run(done) {
+  run(files, done) {
     console.log('DragDrop running!');
     // console.log(files);
     this.listenForEvents();

+ 1 - 1
src/plugins/Tus10.js

@@ -6,7 +6,7 @@ export default class Tus10 extends TransloaditPlugin {
     this.type = 'uploader';
   }
 
-  run(done) {
+  run(files, done) {
     // console.log(files);
     this.core.setProgress(this, 0);
     var uploaded = [];