plugin-module/modeler-plugin-code/backend/main.js
/**
 * Wrapper to make sure that wrapped function is executed only once.
 *
 * @param {function} fn
 */
Wrapper to make sure that wrapped function is executed only once.
@param {function} fn
Wrapper to make sure that wrapped function is executed only once . @param { function } fn
function executeOnce(fn) {
  let executed = false;
  let returnValue = [];
  let javaPaths;
  let jdk = {
    jdk: null,
    set working(newJdk) {
      this.jdk = newJdk;
    }
  };
  return function(...args) {
    let app = args[0];
    if (executed) {
      let { menus } = buildMenu(javaPaths, jdk, ...args);
      returnValue = menus;
      return returnValue;
    }
    executed = true;
    fn(jdk, ...args).then(result => {
      javaPaths = result.javaPaths;
      returnValue = result.menus;
    }).catch(error => {
      app.emit('menu:action', 'show-dialog', {
        message: 'Couldn\'t start Groovy executor: ' + error,
        title: 'Camunda Code Editor Error',
        type: 'error'
      });
    });
    return returnValue;
  };
}
function executeOnce ( fn ) { let executed = false ; let returnValue = [ ] ; let javaPaths ; let jdk = { jdk : null , set working ( newJdk ) { this . jdk = newJdk ; } } ; return function ( ... args ) { let app = args [ 0 ] ; if ( executed ) { let { menus } = buildMenu ( javaPaths , jdk , ... args ) ; returnValue = menus ; return returnValue ; } executed = true ; fn ( jdk , ... args ) . then ( result => { javaPaths = result . javaPaths ; returnValue = result . menus ; } ) . catch ( error => { app . emit ( 'menu:action' , 'show-dialog' , { message : 'Couldn\'t start Groovy executor: ' + error , title : 'Camunda Code Editor Error' , type : 'error' } ) ; } ) ; return returnValue ; } ; }
Wrapper to make sure that wrapped function is executed only once.
Wrapper to make sure that wrapped function is executed only once .