Created
January 28, 2019 22:09
-
-
Save tadjik1/47bd1cd41d7e39f4b7d0827490bccd19 to your computer and use it in GitHub Desktop.
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
// current | |
const [rendered, type] = await (async () => { | |
const articleRenderer = new ArticleRenderer(); | |
const taskRenderer = new TaskRenderer(); | |
if (doc instanceof Article) { | |
return [await articleRenderer.render(doc), 'article']; | |
} else if (doc instanceof Task) { | |
return [await taskRenderer.render(doc), 'task']; | |
} else { | |
throw new Error("Unknown doc type"); | |
} | |
})(); | |
// future | |
const [rendered, type] = do { | |
const articleRenderer = new ArticleRenderer(); | |
const taskRenderer = new TaskRenderer(); | |
if (doc instanceof Article) { | |
[await articleRenderer.render(doc), 'article']; | |
} else if (doc instanceof Task) { | |
[await taskRenderer.render(doc), 'task']; | |
} else { | |
throw new Error("Unknown doc type"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment