Last active
March 5, 2020 03:58
-
-
Save jwulf/bc75bd014393be0a39a70f14f5bc2976 to your computer and use it in GitHub Desktop.
A code example from the article https://www.joshwulf.com/blog/2020/03/array-async-failure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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