Skip to content

Kadeluxe/AsyncTask

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AsyncTask

Resolve Promises outside them

Example

import {AsyncTask} from "@kadeluxe/async-task";

function getAsyncTask() {
  const task = new AsyncTask<number>();
  
  process.nextTick(() => task.resolve(1337));
  
  return task;
}

getAsyncTask().then(console.log); // -> 1337

AsyncTask is typed and implements Promise interface, so you can treat it as a normal Promise.