How to use the dojo/Deferred function in dojo

To help you get started, we’ve selected a few dojo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wri / gfw-fires-app / src / map / js / utils / loaders.js View on Github external
loadJS: (url, async) => {

    let deferred = new Deferred();

    let script = document.createElement('script');
    script.src = url;
    script.async = async || false;
    script.onload = deferred.resolve();
    script.onerror = deferred.reject();
    requestAnimationFrame(function () { document.getElementsByTagName('head')[0].appendChild(script); });

    // let promise = new Promise((resolve, reject) => {
    //   let script = document.createElement('script');
    //   script.src = url;
    //   script.async = async || false;
    //   script.onload = resolve;
    //   script.onerror = reject;
    //   requestAnimationFrame(function () { document.getElementsByTagName('head')[0].appendChild(script); });
    // });
github wri / gfw-mapbuilder / src / js / utils / layerInfoCache.js View on Github external
fetch (layer, cartoId) {
    const promise = new Deferred();
    let url;
    // If a technicalName is configured, fetch from the metadata API
    // else, attempt to fetch it from the mapservice
    if (layer.technicalName) {
      url = `${urls.metadataApi}/${layer.technicalName}`;
      getMetadataTask(url).then(results => {
        _cache[layer.id] = results;
        promise.resolve(results);
      });
    } else if (layer.itemId) {
      // This commented out URL contains a good item id to use for testing
      // url = urls.metadataXmlEndpoint('30e234e880c94a2ca54be9a132808eae');
      url = urls.metadataXmlEndpoint(layer.itemId);
      getXMLTask(url).then(xmlDocument => {
        promise.resolve(reduceXML(xmlDocument));
      }, () => {
github wri / gfw-fires-app / src / map / js / components / Modals / CalendarModal.js View on Github external
getLatest (method: string) {
		let deferred = new Deferred();
		let qLayer;
		if (method === 'changeRisk') {
			qLayer = layersConfig.filter(layer => layer && layer.id === KEYS.fireWeather)[0];
		} else {
			qLayer = layersConfig.filter(layer => layer && layer.id === KEYS.lastRainfall)[0];
		}
		let queryTask = new QueryTask(qLayer.url);
		let query = new Query();
		query.where = '1=1';
		query.returnGeometry = false;
		query.outFields = ['OBJECTID', 'Name'];
		// We sort by OBJECTID because we want to get the most recent image as the first returned feature
		query.orderByFields = ['OBJECTID DESC'];

		queryTask.execute(query, (results) => {
			let newest = results.features[0];
github Esri / storymap-crowdsource / src / app / utils / arcgis / portal / Portal.babel.js View on Github external
Portal.prototype.createService = function (options) {
  const deferred = new Deferred();
  const fsState = lang.getObject('items.featureService',false,AppStore.getState());
  const defaults = fsState;
  const settings = $.extend(true, {}, defaults, options);
  const username = this.getPortalUser().username;
  const token = this.getPortalUser().credential.token;
  const baseRequestPath = this.portalUrl.stripTrailingSlash() + '/content/users/' + username + (settings.item.ownerFolder ? ('/' + settings.item.ownerFolder) : '');
  let response = {};

  // Transform arrays
  settings.item.tags = settings.item.tags ? settings.item.tags.join(',') : '';
  settings.item.typeKeywords = settings.item.typeKeywords.join(',');

  const createFeatureService = function createFeatureService() {
    const dfd = new Deferred();
    const url = baseRequestPath + '/createService';
github Esri / storymap-cascade / src / app / storymaps / tpl / view / media / WebMap.jsx View on Github external
performAction(params = {}) {
    var resultDeferred = new Deferred();
    var map = this._cache[this.id] ? this._cache[this.id].map : null;

    if (params.isActive === false && ! params.isNewView) {
      return;
    }

    if (! map) {
      resultDeferred.reject();
      return resultDeferred;
    }

    if (params.scrollPositionView) {
      this._lastScrollPosition = params.scrollPositionView;
    }

    if (params.transition) {
github Esri / storymap-crowdsource / src / app / components / forms / photo / Photo.babel.js View on Github external
});

        if (dfd) {
          return dfd;
        } else {
          this.setState({
            resizingPhoto: false
          });
          return value;
        }
      } else if (typeof this.props.extras.photoSettings === 'object') {
        const options = $.extend(true,{},{rawPhotoCanvas,optimizedPhotoCanvas},this.props.extras.photoSettings);
        const photo = this.generateOptimizedPhoto(options);

        if (photo.then) {
          const dfd = new Deferred();

          photo.then((res) => {
            dfd.resolve(res);
          });
          return dfd;
        } else {
          return value;
        }
      }
    }
  }
github Esri / storymap-crowdsource / src / app / components / forms / photo / Photo.babel.js View on Github external
this.props.extras.photoSettings.forEach((photoSettings,index) => {
          const name = photoSettings.name ? photoSettings.name : 'photo' + index;
          const options = $.extend(true,{},{rawPhotoCanvas,optimizedPhotoCanvas},photoSettings);
          const photo = this.generateOptimizedPhoto(options);

          value[name] = false;

          if (photo.then) {
            if (!dfd) {
              dfd = new Deferred();
            }
            photo.then((res) => {
              value[name] = res;
              if (isFinished()) {
                if (dfd) {
                  this.setState({
                    resizingPhoto: false
                  });
                  dfd.resolve(value);
                } else {
                  return value;
                }
              }
            });
          } else {
            value[name] = photo;
github Esri / storymap-crowdsource / src / app / stores / CrowdsourceAppStore.babel.js View on Github external
const _saveGraphic = function saveGraphic () {
  const dfd = new Deferred();
  let g = $.extend(true,{},_contributeGraphic);
  let attachments = [];

  if (g.attributes) {
    $.each(g.attributes, (key,value) => {
      if (typeof value === 'object' && value.attachment && value.type) {
        switch (value.type) {
          case 'photo':
            g.attributes[key] = 'ATTACHMENT_' + key;
            attachments.push({
              field: key,
              filename: key + value.ext,
              attachment: Helper.attachmentUtils.dataURItoBlob(value.source)
            });
            break;
        }
github Saleslogix / argos-saleslogix / src / Integrations / BOE / Promote.js View on Github external
getAccountingSystem: function getAccountingSystem() {
    if (!this._busy) {
      this._busy = new BusyIndicator({ id: `${this.id}__busyIndicator` });
      this._accountingBusy = new BusyIndicator({ id: `${this.id}__busyIndicator__accounting`, size: 'small', label: null, containerClass: 'busyField' });
      this._accountingBusy.start();
    }
    this._firstLoad = true;
    App.modal.showToolbar = false;
    App.modal.disableClose = true;
    App.modal.add(this._busy);
    this._busy.start();
    this._accountingDeferred = new Deferred();
    this.initBackOfficeModel();
    this.initIntegrationMappingModel();
    this.initAccountingEntitiesModel();
    return this._accountingDeferred.promise;
  },
  getContent: function getContent() {
github Esri / storymap-crowdsource / src / app / utils / arcgis / portal / Portal.babel.js View on Github external
const createFeatureService = function createFeatureService() {
    const dfd = new Deferred();
    const url = baseRequestPath + '/createService';

    const content = $.extend(true, settings.item, {
      createParameters: JSON.stringify(settings.serviceDefinition),
      outputType: 'featureService',
      f: 'json'
    });

    esriRequest({
      url,
      handleAs: 'json',
      content
    },{
      usePost: true
    }).then((res) => {
      if (res.success) {

dojo

Dojo core is a powerful, lightweight library that makes common tasks quicker and easier. Animate elements, manipulate the DOM, and query with easy CSS syntax, all without sacrificing performance.

BSD-3-Clause OR AFL-2.1
Latest version published 2 years ago

Package Health Score

60 / 100
Full package analysis