Sha256: 49ae7023376eb1de0bb24b65650c7fab9760b6e3e2fdaa7c538992ee0016fc6a

Contents?: true

Size: 489 Bytes

Versions: 10

Compression:

Stored size: 489 Bytes

Contents

type ReadyHandlerFunc = () => void;

const readyHandlers: ReadyHandlerFunc[] = [];

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

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

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

export default new ReadyHandler();

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
pages_core-3.15.5 app/javascript/lib/readyHandler.ts
pages_core-3.15.4 app/javascript/lib/readyHandler.ts
pages_core-3.15.3 app/javascript/lib/readyHandler.ts
pages_core-3.15.2 app/javascript/lib/readyHandler.ts
pages_core-3.15.1 app/javascript/lib/readyHandler.ts
pages_core-3.14.0 app/javascript/lib/readyHandler.ts
pages_core-3.13.0 app/javascript/lib/readyHandler.ts
pages_core-3.12.7 app/javascript/lib/readyHandler.ts
pages_core-3.12.6 app/javascript/lib/readyHandler.ts
pages_core-3.12.5 app/javascript/lib/readyHandler.ts