-
Notifications
You must be signed in to change notification settings - Fork 0
How to include
Eugene Lazutkin edited this page Nov 26, 2019
·
8 revisions
heya-io can be installed with npm (newer versions install packages using a flat structure) or bower. The former put packages into node_modules/, the latter put into bower_components/. In the examples below, we assume that npm was used.
AMD is the easiest option, because it takes care of all dependencies. Example (based on tests.html):
<!DOCTYPE html>
<html>
<head>
<title>Example</title>
<script>
require.config({
baseUrl: ".",
packages: [
{name: "heya-async", location: "node_modules/heya-async"},
{name: "heya-io", location: "node_modules/heya-io"}
],
paths: {
domReady: "http://cdnjs.cloudflare.com/ajax/libs/require-domReady/2.0.1/domReady.min"
}
});
require(
["heya-io/io", "heya-async/FastDeferred", "domReady!"],
function(io, Deferred){
io.Deferred = Deferred; // use custom fast deferred
// more code that use io()
}
);
</script>
</head>
<body>
<!-- some HTML stuff -->
</body>
</html>The map of AMD modules:
| File name | Returns | Defines | Description |
|---|---|---|---|
io.js |
io |
The main functionality | |
jsonp.js |
jsonp |
JSON-P transport | |
load.js |
load |
<script> transport |
|
fetch.js |
io |
io.fetch |
fetch() transport |
bust.js |
io |
Cache-busting helper. | |
mock.js |
io |
io.mock |
Mock service. |
track.js |
io |
io.track |
Track service. |
cache.js |
io |
io.cache |
Cache service. |
bundle.js |
io |
io.bundle |
Bundle service. |
retry.js |
io |
io.retry |
Retry service. |
FauxXHR.js |
FauxXHR |
General utility. | |
scaffold.js |
scaffold |
Service utility. | |
main.js |
io |
Main + cache + bundle | |
url.js |
url |
url tagged literals |
Using globals is easy too, but requires to be careful with dependencies:
<!DOCTYPE html>
<html>
<head>
<title>Example</title>
<script src="node_modules/heya-async/dist/Micro.js"></script>
<script src="node_modules/heya-async/dist/FastDeferred.js"></script>
<script src="node_modules/heya-io/dist/io.js"></script>
<script>
heya.io.Deferred = heya.async.FastDeferred;
// more code that use io()
</script>
</head>
<body>
<!-- some HTML stuff -->
</body>
</html>By default, heya-io uses heya.io global namespace. Mapping of files to globals:
| File name | Global | Description |
|---|---|---|
dist/io.js |
heya.io |
The main functionality |
dist/jsonp.js |
heya.io.jsonp |
JSON-P transport |
dist/load.js |
heya.io.load |
<script> transport |
dist/fetch.js |
heya.io.fetch |
fetch() transport |
dist/bust.js |
heya.io |
Cache-busting helper. |
dist/mock.js |
heya.io.mock |
Mock service. |
dist/track.js |
heya.io.track |
Track service. |
dist/cache.js |
heya.io.cache |
Cache service. |
dist/bundle.js |
heya.io.bundle |
Bundle service. |
dist/retry.js |
heya.io.retry |
Retry service. |
dist/FauxXHR.js |
heya.io.FauxXHR |
General utility. |
dist/scaffold.js |
heya.io.scaffold |
Service utility. |
dist/main.js |
heya.io |
Main + cache + bundle |
dist/url.js |
heya.io.url |
url tagged literals |
Implicitly io does not depend on any other package. Following internal dependencies are exist between files in dist/:
-
io.js— no dependencies. -
FauxXHR.js— no dependencies. -
scaffold.js— no dependencies -
jsonp.js—io.js -
load.js—io.js -
fetch.js—io.js,FauxXHR.js -
bust.js—io.js -
track.js—io.js,scaffold.js -
cache.js—io.js,scaffold.js,FauxXHR.js -
bundle.js—io.js,scaffold.js,track.js,FauxXHR.js -
retry.js—io.js,scaffold.js -
mock.js—io.js,scaffold.js,FauxXHR.js -
url.js— no dependencies.