Skip to content

Instantly share code, notes, and snippets.

@jwulf
Last active March 5, 2020 03:58
Show Gist options
  • Save jwulf/bc75bd014393be0a39a70f14f5bc2976 to your computer and use it in GitHub Desktop.
Save jwulf/bc75bd014393be0a39a70f14f5bc2976 to your computer and use it in GitHub Desktop.
class AsyncTask<T> {
_run: () => Promise<T>;
_success: (result: T) => void;
_error: (e: Error) => void;
constructor({
error,
run,
success
}: {
error: (e: Error) => void;
run: () => Promise<T>;
success: (result: T) => void;
}) {
this._run = run;
this._success = success;
this._error = error;
}
run = () => this._run()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment