Use async keyword instead of Promises

This commit is contained in:
Yuri Astrakhan 2017-12-08 19:09:11 -05:00 committed by GitHub
parent acde688097
commit 43e68c519a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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');
}
@ -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');
}
@ -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) => {