How to use the @polymer/polymer/lib/utils/async.js.microTask function in @polymer/polymer

To help you get started, we’ve selected a few @polymer/polymer 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 elmsln / lrnwebcomponents / elements / lrndesign-contentsequencer / lib / lrndesign-contentsequencer-step.js View on Github external
_activeChanged: function() {
    var contentsequencer = dom(this).parentNode;

    // Don't syntax highlight code if lrndesign-contentsequencer requests it.
    if (
      contentsequencer.localName === "lrndesign-contentsequencer" &&
      contentsequencer.noHighlight
    ) {
      return;
    }

    if (this.active && !this._isHighlighted) {
      // Minimize jank by waiting one click to do syntax highlighting.
      async.microTask.run(() => {
        var blocks = dom(this).querySelectorAll("pre > code");
        blocks.forEach(
          function(block) {
            // TODO: consider pre-escaping markup on server.
            dom(block).innerHTML = prettyPrintOne(
              encodeHTMLEntities_(block.textContent)
            );

            block.addEventListener(
              "copy",
              function() {
                this.fire("lrndesign-contentsequencer-snippet-copy", {
                  snippet: block.textContent
                });
              }.bind(this)
            );
github elmsln / lrnwebcomponents / elements / lrnsys-comment / lrnsys-comment.es6.js View on Github external
_editTrigger(e) {
    // bother checking if they can edit or not first
    if (typeof this.comment !== typeof undefined && this.comment.actions.edit) {
      async.microTask.run(() => {
        // show / hide the edit vs display area
        this.$.renderedcomment.hidden = this.editform;
        this.$.commenteditor.hidden = !this.editform;
        // simple icon toggle
        if (this.editform) {
          this.$.edit.icon = "save";
          this.$.edit.alt = "Save";
          this.$.reply.disabled = true;
          this.$.editcomment.focus();
          this.dispatchEvent(
            new CustomEvent("comment-editing", {
              bubbles: true,
              cancelable: true,
              composed: true,
              detail: { comment: this.comment }
            })
github elmsln / lrnwebcomponents / elements / lrndesign-contentsequencer / lib / lrndesign-contentsequencer.js View on Github external
_stateLoaded: function() {
    // allow everything render and initialize,
    // especially this.steps which runs at the same init level
    // as iron-localstorage (on attached).
    async.microTask.run(() => {
      this._storedStep = this.steps[this.state.stepIndex];
      // resume dialog is shown only when all 3 conditions hold:
      // 1. user has already visited the contentsequencer in the past
      // 2. has made at least 1 step
      // 3. user is landed on the first step
      if (this.selected === 0 && this.state.stepIndex > 0) {
        this.$.resumeDialog.open();
      }
    });
  },
github elmsln / lrnwebcomponents / elements / outline-designer / outline-designer.js View on Github external
case "low":
          this.detailsModeIcon = "icons:apps";
          this.detailsModeLabel = "Low";
          break;
        case "mid":
          this.detailsModeIcon = "icons:view-module";
          this.detailsModeLabel = "Medium";
          break;
        case "high":
          this.detailsModeIcon = "icons:view-carousel";
          this.detailsModeLabel = "High";
          break;
      }
      // fire resize event if iron-list is visible
      if (this.selectedView === 0) {
        async.microTask.run(() => {
          setTimeout(() => {
            this.shadowRoot.querySelector("#ironlist").dispatchEvent(
              new CustomEvent("iron-resize", {
                bubbles: true,
                cancelable: true,
                composed: true,
                detail: true
              })
            );
            window.dispatchEvent(new Event("resize"));
          }, 50);
        });
      }
    }
  }
  /**
github avdaredevil / highcharts-chart / highcharts-behavior.js View on Github external
setData(x,z) {
                const __app = this, isArr = x instanceof Array
                if (!isArr) {x = _extends({name: (this.label||this.yLabel||this.xLabel),colorByPoint: this.colorByPoint},x)}
                if (x && x.length && x[0].data instanceof Array) {
                    async.microTask.run(_ => {
                        while (__app._chart.series.length) {
                            __app.removeSeries(0,false)
                        }
                        x.forEach(d => __app._chart.addSeries(d))
                    }, __app.__microTaskDelaySetData); 
                } else {__app._getSeries(z)[isArr?"setData":"update"](x)}
            }
            addData(x,y,z,drillable) {this.pushData(x,y,z,true,drillable)}
github elmsln / lrnwebcomponents / elements / lrnsys-outline / lrnsys-outline.es6.js View on Github external
setTimeout(() => {
      this.__focusedItem = this.activeItem.previousElementSibling;
      for (var k in this.items) {
        if (this.items[k].parent == this.items[i].id) {
          this.items[k].parent = this.items[i].parent;
        }
      }
      this.activeItem.classList.remove("collapse-to-remove");
      this.splice("items", i, 1);
      if (this.__focusedItem !== undefined && this.__focusedItem !== null) {
        async.microTask.run(() => {
          setTimeout(() => {
            this.__focusedItem.focus();
          }, 50);
        });
      }
    }, 300);
  }
github elmsln / lrnwebcomponents / elements / paper-lightbox / lib / paper-lightbox.js View on Github external
ready: function() {
      var t;
      return (
        (t = this),
        async.microTask.run(() => {
          return setTimeout(function() {
            return t._onLoad();
          });
        })
      );
    },
    _createPopup: function() {
github elmsln / lrnwebcomponents / elements / paper-lightbox / paper-lightbox.js View on Github external
ready: function() {
      var t;
      return (
        (t = this),
        async.microTask.run(() => {
          return setTimeout(function() {
            return t._onLoad();
          });
        })
      );
    },
    _createPopup: function() {
github elmsln / lrnwebcomponents / elements / paper-lightbox / src / paper-lightbox.js View on Github external
ready: function() {
      var t;
      return (
        (t = this),
        async.microTask.run(() => {
          return setTimeout(function() {
            return t._onLoad();
          });
        })
      );
    },
    _createPopup: function() {
github elmsln / lrnwebcomponents / elements / hax-body / hax-body.js View on Github external
setTimeout(() => {
      async.microTask.run(this._keepContextVisible());
    }, 100);
  }