Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Callback pattern
- function reportToMotherShip(callback: GenericAsyncCallback<Error, never>) {
- console.log(`Sending results to the mothership...`);
- asyncApi((error, result) => {
- if (error) {
- console.error(`Failed to get results, cancelling message.`);
- callback(error);
- } else {
- asyncDoSomethingWithResult(result, (error, message) => {
- if (error) {
- console.error(`Failed to send results to the mothership.`)
- callback(error);
- } else {
- console.log(`Message from the mothership: ${message}`);
- callback(null);
- }
- })
- }
- })
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement