P
P
proger_brut2019-07-17 14:55:43
JavaScript
proger_brut, 2019-07-17 14:55:43

How to wrap a vue object in a Promise?

I want to make a dialogue on vue.js with a return value.
It turns out something like this:

static changeSizeDialog(direction, currentValue){
    return new Promise((resolve, reject) => {
      const dialog = new Vue({
        el: '#dialogChangeSize',
        data: {
          show: true,
          direction: direction,
          value: currentValue,
        },
        methods:{
          closeDialog(){
            this.show = false;
            dialog.$destroy();
            dialog.$el.remove();
          },
          setSize: function(value){
            this.closeDialog();
            resolve(value);
          }
        }
      });
    });
  }

I want to make the dialog call simple, something like this:
Aperture.dialogChangeSize(param1, param2).then((result) => {...})

How to implement this?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question