YLoader provides a per platform http loader class.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
.gitignore
LICENSE
README.md
build.xml
yhaxen.json

README.md

YLoader provides a per platform http loader class.

Example

import yloader.impl.js.XMLHttpRequestLoader;
import yloader.valueObject.Parameter;
import yloader.valueObject.Request;
import yloader.valueObject.Response;

var request = new Request("http://domain.com/service");
request.setHeader(new Parameter("header1", "value1"));
request.setGetParameter(new Parameter("param1", "value1"));

var loader = new XMLHttpRequestLoader(request); // or use Loader.create()
loader.onResponse = onResponse;
loader.load();

function onResponse(response:Response)
{
	if(response.success)
		trace("Response received " + response.data);
	else
		trace("Request failed");
}

Loading Bytes

import haxe.io.Bytes;
import js.html.XMLHttpRequestResponseType;

var loader = Loader.create(request);
loader.onResponse = onResponse
loader.load();
cast(loader, XMLHttpRequestLoader).xhr.responseType = XMLHttpRequestResponseType.ARRAYBUFFER;

function onResponse(response:Response)
{
	var bytes = Bytes.ofData(response.data);
}

Compilation

YLoader contains multiple platform specific implementations. NodeLoader requires hxnodejs dependency which is part of haxelib.json and contains build macro to add extra line into the output.js file:

if (process.version < "v4.0.0") console.warn("Module " + (typeof(module) == "undefined" ? "" : module.filename) + " requires node.js version 4.0.0 or higher");

To avoid this extra line, either include YLoader using -cp flag or turn off the macro by -lib yloader -D hxnodejs_no_version_warning:

haxe -main Main -js main.js -lib yloader -D hxnodejs_no_version_warning

Release

haxelib run yhaxen release -version 0.0.5 -message "Changes..."

Install

Recommended installation from haxelib:

haxelib install yloader