Easy-to-use event-loop dispatcher framework for D-based applications http://deavmi.assigned.network/projects/eventy
Go to file
Tristan B. Velloza Kildaire 73bec426e0 Task
- Fixed missing `eventy.result` import to resolve the `Result` type
2023-03-03 17:32:39 +02:00
logos New logo 2021-12-27 12:29:47 +02:00
source/eventy Task 2023-03-03 17:32:39 +02:00
.gitignore - Update .gitignore 2023-03-03 17:17:07 +02:00
LICENSE Updated licensing information 2021-09-08 12:42:55 +02:00
README.md Added usage of the `then` call 2023-02-22 16:57:00 +02:00
dub.json Dub 2023-03-03 17:16:58 +02:00

README.md

Eventy

What I want

// Create en event engine (it logs promises)
Eventy eventy = new Eventy();

/**
 * Create a new promise who's job is to run the
 * provided lambda `(x) => (x*2)`
 */
Promise myPromise = eventy.new((x) => (x*2));

/**
 * Chain a promise to this one such that upon completion of
 * `myPromise` then `promise2` will run and `myPromise` will only
 * be considered completely done once everything from its chain forward is
 *
 * NOTE: That a promise is only completed then once its chain forwards
 * is completed
 */
Promise promise2 = eventy.new((x)=>());
myPromise.then(promise2);

/**
 * Now start the promise and await its completion,
 * this will basically sleep the calling thread
 * till it awakes. It returns a result
 *
 * Internally this calls `this.execute()` and
 * then `await()` on the calling thread (as
 * described above)
 */
Result result = myPromise.await();

/**
 * One can also just start a promise without awaiting it,
 * however the result will have to be grabbed manually later
 */
myPromise.execute();

/**
 * The status of a promise can be checked
 *
 * TODO: There should be a version
 */
if(myPromise.state == State.Finished)
{

}

/**
 * You can call await (it won't start it again)
 * but will rather sleep like await first call.
 *
 * If it has finished then result is returned.
 * It can be called over and over and the result
 * will just be returned.
 */
Result result = myPromise.await();