delay

Delays a callback until the nextframe, byFrames or byTime
https://github.com/peteshand/delay

To install, run:

haxelib install delay 1.2.3 

See using Haxelib in Haxelib documentation for more information.

README.md

Overview

This little utility allows you to delay a callback until the nextframe, byFrames or byTime

Next Frame Delay

Delay.nextFrame(() -> {
	// trigger on next frame
});

Frame Delay

Delay callback function by 5 of frames.

Delay.byFrames(5, () -> {
	// triggers after 5 frames
});

Time Delay

Delay callback function by 2 seconds.

Delay.byTime(2, () -> {
	// triggers after 2 seconds
});

The default time unit is seconds, however this can be changed by settings the last argument to one of the following options:

TimeUnit.MILLISECONDS
TimeUnit.SECONDS
TimeUnit.MINUTES
TimeUnit.HOURS
TimeUnit.DAYS

eg:

Delay.byTime(2, () -> {
	// triggers after 2 minutes
}, TimeUnit.MINUTES);

Passing Argument

Delay callback function until the next frame and pass parameters.

Delay.nextFrame((value:int, str:String) -> {
	// trigger on next frame with params
}, [1, "test"]);
}

Delay callback function by X number of frames and pass parameters.

Delay.byFrames(5, (value:int, str:String) -> {
	// triggers after 5 frames
}, [1, "test"]);

Delay callback function by X amount of time pass parameters.

Delay.byTime(200, (value:int, str:String) -> {
	// triggers after 200 milliseconds
}, [1, "test"], TimeUnit.MILLISECONDS);```

Contributors
p.j.shand
Version
1.2.3
Published
7 years ago
Dependencies
License
MIT

All libraries are free

Every month, more than a thousand developers use Haxelib to find, share, and reuse code — and assemble it in powerful new ways. Enjoy Haxe; It is great!

Explore Haxe

Haxe Manual

Haxe Code Cookbook

Haxe API documentation

You can try Haxe in the browser! try.haxe.org

Join us on GitHub!

Haxe is being developed on GitHub. Feel free to contribute or report issues to our projects.

Haxe on GitHub