Skip to content

Instantly share code, notes, and snippets.

@tadjik1
Created January 28, 2019 22:09
Show Gist options
  • Save tadjik1/47bd1cd41d7e39f4b7d0827490bccd19 to your computer and use it in GitHub Desktop.
Save tadjik1/47bd1cd41d7e39f4b7d0827490bccd19 to your computer and use it in GitHub Desktop.
// 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