J
J
jtag2018-03-02 14:51:21
JavaScript
jtag, 2018-03-02 14:51:21

How to initialize object property with async function?

let data = new  function(){
        (async ()=> {
            return new Promise(resolve => {
                    ipcRenderer.send('message', 'ping');
                    ipcRenderer.on('reply', (event, arg) => {
                        resolve(arg);
                    })
            })
        });
    }

    let obj = {
        data: data
    }
    console.log(obj)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
RidgeA, 2018-03-02
@RidgeA

There can be several approaches here
: 1. make a factor that will asynchronously return an object initialized with data
2. make an init function in the object that will work asynchronously and return an initialized object.
3. surely there is something else....

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question