Skip to content

Commit

Permalink
Use async keyword instead of Promises (elastic#15526)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasneirynck authored Dec 11, 2017
1 parent fd75aeb commit b58beed
Showing 1 changed file with 11 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,10 @@ class MyVisualization {
this.el = el;
this.vis = vis;
}
render(visData, status) {
return new Promise(resolve => {
...
resolve('done rendering');
}),
async render(visData, status) {
...
return 'done rendering';
}
destroy() {
console.log('destroying');
}
Expand Down Expand Up @@ -249,11 +248,10 @@ class MyEditorController {
this.config = vis.type.editorConfig;
}
async render(visData) {
return new Promise(resolve => {
console.log(this.config.my);
...
resolve('done rendering');
}),
console.log(this.config.my);
...
return 'done rendering';
}
destroy() {
console.log('destroying');
}
Expand Down Expand Up @@ -307,12 +305,9 @@ It's up to function to decide when it wants to issue a new request or return pre
-----------
import { VisFactoryProvider } from 'ui/vis/vis_factory';
const myRequestHandler = (vis, appState, uiState, searchSource) => {
return new Promise((resolve, reject) => {
const data = ... parse ...
resolve(data);
});
const myRequestHandler = async (vis, appState, uiState, searchSource) => {
const data = ... parse ...
return data;
};
const MyNewVisType = (Private) => {
Expand Down

0 comments on commit b58beed

Please sign in to comment.