How to use the @jupyter-widgets/base.resolvePromisesDict function in @jupyter-widgets/base

To help you get started, we’ve selected a few @jupyter-widgets/base 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 QuantStack / ipysheet / js / src / sheet.ts View on Github external
}
        }
        for (let key in this.widget_views) {
            if(this.widget_views.hasOwnProperty(key)) {
                // Ugly, this should be properly done
                let [row, col] = String(key).split(',').map(x => parseInt(x));
                let widget_view = this.widget_views[key];
                if(data[row][col] && data[row][col].value && data[row][col].value.cid == widget_view.model.cid) {
                    // good, the previous widget_view should be reused
                } else {
                    // we have a leftover view from the previous run
                    widget_view.remove();
                }
            }
        }
        this.widget_views = await widgets.resolvePromisesDict(widget_view_promises)
    },
    async _build_table() {
github jupyter-widgets / midicontrols / src / widget.ts View on Github external
async setup() {
    // Create control widgets
    return resolvePromisesDict({
      buttons: Promise.all(this._createButtons()),
      side_buttons: Promise.all(this._createSideButtons()),
      rotary_encoders: Promise.all(this._createRotaryEncoders()),
      rotary_buttons: Promise.all(this._createRotaryButtons()),
      faders: Promise.all(this._createFaders())
    });
  }
github danielfrg / jupyter-flex / js / src / components / App / WidgetManager.js View on Github external
}
            }

            // 2. Make hash based on the controlValues
            let hash = this.hash_fn(controlValues);

            // 3. Update affected widgets
            const outputValue = outputOnChangeData["values"][hash];
            if (outputValue !== undefined) {
                const key = this.getWidgetValueKey(outputModel["_model_name"]);
                state["state"][outputId]["state"][key] = outputValue;

                // If its an OutputModel clear the state
                // This avoids objects being outputed multiple times
                // based on this.clear_state()
                await resolvePromisesDict(this._models).then((models) => {
                    Object.keys(models).forEach((id) => {
                        let model = models[id];
                        if (model.name == "OutputModel") {
                            models[id].close();
                            this._models[model.model_id] = null;
                        }
                    });
                });

                await this.set_state(state);
                if (outputModel["_model_name"] == "OuptuModel") {
                    this.renderWidget(outputId);
                }
            }
        });
    }
github bloomberg / bqplot / js / src / Mark.ts View on Github external
set_scale_views: function() {
        // first, if this.scales was already defined, unregister from the
        // old ones.
        for (var key in this.scales) {
            this.stopListening(this.scales[key]);
        }

        var scale_models = this.model.get("scales");
        var that = this;
        var scale_promises = {};
        _.each(scale_models, function(model, key) {
            scale_promises[key] = that.create_child_view(model);
        });
        return widgets.resolvePromisesDict(scale_promises).then(function(scales) {
            that.scales = scales;
            that.set_positional_scales();
            that.initialize_additional_scales();
            that.set_ranges();
            that.trigger("mark_scales_updated");
        });
    },
github bloomberg / bqplot / js / src / PanZoom.ts View on Github external
update_scales() {
        const scales = this.model.get("scales");
        const that = this;
        this.scale_promises = widgets.resolvePromisesDict({
            "x": Promise.all((scales.x || []).map(function(model : widgets.WidgetModel) {
                    return that.create_child_view(model);
                 })),
            "y": Promise.all((scales.y || []).map(function(model : widgets.WidgetModel) {
                    return that.create_child_view(model);
                 })),
        });
        widgets.resolvePromisesDict(this.scale_promises)
            .then(_.bind(this.set_ranges, this));
    }
github bloomberg / bqplot / js / src / PanZoom.ts View on Github external
update_scales() {
        const scales = this.model.get("scales");
        const that = this;
        this.scale_promises = widgets.resolvePromisesDict({
            "x": Promise.all((scales.x || []).map(function(model : widgets.WidgetModel) {
                    return that.create_child_view(model);
                 })),
            "y": Promise.all((scales.y || []).map(function(model : widgets.WidgetModel) {
                    return that.create_child_view(model);
                 })),
        });
        widgets.resolvePromisesDict(this.scale_promises)
            .then(_.bind(this.set_ranges, this));
    }
github jupyter-widgets / ipyleaflet / js / src / Map.js View on Github external
update_bounds() {
    return widgets.resolvePromisesDict(this.views).then(views => {
      var bounds = {
        north: -90,
        south: 90,
        east: -180,
        west: 180
      };
      Object.keys(views).reduce(function(bnds, key) {
        var obj = views[key].obj;
        if (obj) {
          var view_bounds = obj.getBounds();
          bnds.north = Math.max(bnds.north, view_bounds.getNorth());
          bnds.south = Math.min(bnds.south, view_bounds.getSouth());
          bnds.east = Math.max(bnds.east, view_bounds.getEast());
          bnds.west = Math.min(bnds.west, view_bounds.getWest());
        }
        return bnds;
github bloomberg / bqplot / js / src / MarketMap.ts View on Github external
create_scale_views() {
        for (let key in this.scales) {
            this.stopListening(this.scales[key]);
        }
        const scale_models = this.model.get("scales");
        const that = this;
        const scale_promises = {};
        _.each(scale_models, function(model : widgets.WidgetModel, key) {
            scale_promises[key] = that.create_child_view(model);
        });
        return widgets.resolvePromisesDict(scale_promises).then(function(d) {
            that.scales = d;
            that.set_scales();
        });
    }