Sha256: 7fcdf4027aabb19119bf97ff2f3d457542ed903ca8734aed4cc4389f646ed4c2

Contents?: true

Size: 415 Bytes

Versions: 15

Compression:

Stored size: 415 Bytes

Contents

let readyHandlers = [];

const handleState = () => {
  if (["interactive", "complete"].indexOf(document.readyState) > -1) {
    while(readyHandlers.length > 0) {
      (readyHandlers.shift())();
    }
  }
};

class ReadyHandler {
  constructor () {
    document.onreadystatechange = handleState;
  }

  ready (handler) {
    readyHandlers.push(handler);
    handleState();
  }
}

export default new ReadyHandler();

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
pages_core-3.12.1 app/javascript/lib/readyHandler.js
pages_core-3.12.0 app/javascript/lib/readyHandler.js
pages_core-3.11.3 app/javascript/lib/readyHandler.js
pages_core-3.11.2 app/javascript/lib/readyHandler.js
pages_core-3.11.1 app/javascript/lib/readyHandler.js
pages_core-3.11.0 app/javascript/lib/readyHandler.js
pages_core-3.10.2 app/javascript/lib/readyHandler.js
pages_core-3.10.1 app/javascript/lib/readyHandler.js
pages_core-3.9.2 app/javascript/lib/readyHandler.js
pages_core-3.9.1 app/javascript/lib/readyHandler.js
pages_core-3.9.0 app/javascript/lib/readyHandler.js
pages_core-3.8.3 app/javascript/lib/readyHandler.js
pages_core-3.8.2 app/javascript/lib/readyHandler.js
pages_core-3.8.1 app/javascript/lib/readyHandler.js
pages_core-3.8.0 app/javascript/lib/readyHandler.js