Options
All
  • Public
  • Public/Protected
  • All
Menu

@labkey/api

Index

Functions

Const MultiRequest

  • MultiRequest(config: any): any
  • Make multiple ajax requests and invokes a callback when all are complete. Requests are added as [function, config] array pairs where the config object is passed as the argument to the request function. The request function's config object argument must accept a success callback named 'success' and a failure callback named 'failure'.

    Parameters

    • config: any

      Either an array of [function, config] array pairs to be added or a config object with the shape:

      • listeners: a config object containing event handlers.
      • requests: an array of [function, config] array pairs to be added.
      var config = {
      schemaName : "assay",
      queryName : protocolName + " Data",
      containerPath : "/Test",
      success: function (data, options, response) {
      console.log("selectRows success: " + data.rowCount);
      },
      failure: function (response, options) {
      console.log("selectRows failure");
      },
      scope: scope // scope to execute success and failure callbacks in.
      };

      // add the requests and config arguments one by one
      var multi = new LABKEY.MultiRequest();
      var requestScope = ... // scope to execute the request function in.
      multi.add(LABKEY.Query.selectRows, config, requestScope);
      multi.add(LABKEY.Query.selectRows, config, requestScope);
      multi.add(LABKEY.Query.selectRows, config, requestScope);
      multi.send(
      function () { console.log("send complete"); },
      sendCallbackScope // scope to execute 'send complete' callback in.
      );

      // additional requests won't be sent while other requests are in progress
      multi.add(LABKEY.Query.selectRows, config);
      multi.send(function () { console.log("send complete"); }, sendCallbackScope);

      // constructor can take an array of requests [function, config] pairs
      multi = new LABKEY.MultiRequest([
      [ LABKEY.Query.selectRows, config ],
      [ LABKEY.Query.selectRows, config ],
      [ LABKEY.Query.selectRows, config ]
      ]);
      multi.send();

      // constructor can take a config object with listeners and requests.
      // if there is a 'done' listener, the requests will be sent immediately.
      multi = new LABKEY.MultiRequest({
      listeners : { 'done': function () { console.log("send complete"); }, scope: sendCallbackScope },
      requests : [ [ LABKEY.Query.selectRows, config ],
      [ LABKEY.Query.selectRows, config ],
      [ LABKEY.Query.selectRows, config ] ]
      });

      // Alternate syntax for adding the 'done' event listener.
      multi = new LABKEY.MultiRequest({
      listeners : {
      'done': {
      fn: function () { console.log("send complete"); }
      scope: sendCallbackScope
      }
      }
      });

    Returns any

getServerContext

  • getServerContext(): LabKey

Generated using TypeDoc