MCPcopy Create free account
hub / github.com/play-co/devkit / getIO

Function getIO

src/web/devkitConn.js:8–35  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6var _pending = [];
7
8function getIO() {
9 return new Promise(function (resolve, reject) {
10 if (typeof io == 'function') {
11 resolve(io);
12 } else if (typeof document == 'undefined') {
13 reject(new Error("No DOM document found"));
14 } else {
15 _pending.push(resolve);
16
17 if (!_script) {
18 _script = document.createElement('script');
19 _script.onload = _script.onreadystatechange = function () {
20 if (typeof io == 'function') {
21 _script.onload = _script.onreadystatechange = null;
22 var cbs = [];
23 _pending = [];
24 cbs.forEach(function (resolve) {
25 resolve(io);
26 });
27 }
28 };
29
30 _script.src = '/socket.io/socket.io.js';
31 document.getElementsByTagName('head')[0].appendChild(_script);
32 }
33 }
34 });
35}
36
37function connect(namespace) {
38 return getIO().then(function (io) {

Callers 1

connectFunction · 0.85

Calls 1

rejectFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…